diff --git a/lib/hooks/thread-hooks.js b/lib/hooks/thread-hooks.js --- a/lib/hooks/thread-hooks.js +++ b/lib/hooks/thread-hooks.js @@ -67,12 +67,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 recipientIDs; if (input.type === threadTypes.THICK_SIDEBAR) { const { parentThreadID, sourceMessageID, initialMemberIDs } = input; invariant( @@ -92,6 +95,9 @@ type: 'create_sidebar', }; op = sidebarOP; + recipientIDs = threadInfos[parentThreadID].members.map( + member => member.id, + ); } else { const { type, initialMemberIDs } = input; @@ -106,20 +112,20 @@ type: 'create_thread', }; op = threadOP; + recipientIDs = [...(input.initialMemberIDs ?? []), viewerID]; } - const userIDs = [...(input.initialMemberIDs ?? []), viewerID]; const opSpecification: OutboundDMOperationSpecification = { type: dmOperationSpecificationTypes.OUTBOUND, op, recipients: { type: 'some_users', - userIDs, + userIDs: recipientIDs, }, }; await processAndSendDMOperation(opSpecification); return threadID; }, - [processAndSendDMOperation, viewerID], + [processAndSendDMOperation, threadInfos, viewerID], ); }