diff --git a/lib/hooks/thread-search-hooks.js b/lib/hooks/thread-search-hooks.js --- a/lib/hooks/thread-search-hooks.js +++ b/lib/hooks/thread-search-hooks.js @@ -103,12 +103,15 @@ state => state.currentUserInfo && state.currentUserInfo.id, ); + const threadInfos = useSelector(state => state.threadStore.threadInfos); + return React.useCallback( async (input: NewThickThreadRequest) => { invariant(viewerID, 'viewerID must be defined'); const threadID = input.id ?? uuid.v4(); let op; + let userIDs; if (input.type === threadTypes.THICK_SIDEBAR) { const { parentThreadID, sourceMessageID, initialMemberIDs } = input; invariant( @@ -128,6 +131,11 @@ type: 'create_sidebar', }; op = sidebarOP; + const memberIDs = [...(input.initialMemberIDs ?? []), viewerID]; + userIDs = [ + ...memberIDs, + ...threadInfos[parentThreadID].members.map(member => member.id), + ]; } else { const { type, initialMemberIDs } = input; @@ -142,8 +150,8 @@ type: 'create_thread', }; op = threadOP; + userIDs = [...(input.initialMemberIDs ?? []), viewerID]; } - const userIDs = [...(input.initialMemberIDs ?? []), viewerID]; const opSpecification: OutboundDMOperationSpecification = { type: dmOperationSpecificationTypes.OUTBOUND, op, @@ -155,7 +163,7 @@ await processAndSendDMOperation(opSpecification); return threadID; }, - [processAndSendDMOperation, viewerID], + [processAndSendDMOperation, threadInfos, viewerID], ); }