diff --git a/api/models/thread.js b/api/models/thread.js index 980822088b..137e6d657a 100644 --- a/api/models/thread.js +++ b/api/models/thread.js @@ -325,7 +325,7 @@ export const getViewableParticipantThreadsByUser = async ( getParticipantCommunityIds, ]); - const participantThreadIds = participantChannelIds.map(c => c.threadId); + const participantThreadIds = participantChannelIds.map(c => c && c.threadId); const distinctParticipantChannelIds = participantChannelIds .map(c => c.channelId) .filter((x, i, a) => a.indexOf(x) === i); diff --git a/api/queries/directMessageThread/participants.js b/api/queries/directMessageThread/participants.js index c9deaac9de..ca4cd4d913 100644 --- a/api/queries/directMessageThread/participants.js +++ b/api/queries/directMessageThread/participants.js @@ -5,14 +5,14 @@ import { signUser } from 'shared/imgix'; export default async ({ id }: { id: string }, _: any, ctx: GraphQLContext) => { const { loaders, user } = ctx; - if (!user || !user.id) return null; + if (!user || !user.id) return []; const canViewThread = await canViewDMThread(user.id, id, loaders); - if (!canViewThread) return null; + if (!canViewThread) return []; return loaders.directMessageParticipants.load(id).then(results => { - if (!results || results.length === 0) return null; + if (!results || results.length === 0) return []; return results.reduction.map(user => { return signUser(user); });