diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index e9f0fc9dc451..c811ae2ff449 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1467,8 +1467,8 @@ function createOptionList(personalDetails: OnyxEntry, repor } const isSelfDM = ReportUtils.isSelfDM(report); - // Currently, currentUser is not included in visibleChatMemberAccountIDs, so for selfDM we need to add the currentUser as participants. - const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : report.visibleChatMemberAccountIDs ?? []; + // Currently, currentUser is not included in participants, so for selfDM we need to add the currentUser as participants. + const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : Object.keys(report.participants ?? {}).map(Number); if (!accountIDs || accountIDs.length === 0) { return; @@ -1688,8 +1688,8 @@ function getOptions( const isPolicyExpenseChat = option.isPolicyExpenseChat; const isMoneyRequestReport = option.isMoneyRequestReport; const isSelfDM = option.isSelfDM; - // Currently, currentUser is not included in visibleChatMemberAccountIDs, so for selfDM we need to add the currentUser as participants. - const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : report.visibleChatMemberAccountIDs ?? []; + // Currently, currentUser is not included in participants, so for selfDM we need to add the currentUser as participants. + const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : Object.keys(report.participants ?? {}).map(Number); if (isPolicyExpenseChat && report.isOwnPolicyExpenseChat && !includeOwnedWorkspaceChats) { return; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 30ab2688b593..98d5b83c332e 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3167,6 +3167,11 @@ function createSplitsAndOnyxData( splitChatReport.lastMessageText = splitIOUReportAction.message?.[0]?.text; splitChatReport.lastMessageHtml = splitIOUReportAction.message?.[0]?.html; + let splitChatReportNotificationPreference = splitChatReport.notificationPreference; + if (splitChatReportNotificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) { + splitChatReportNotificationPreference = CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS; + } + // If we have an existing splitChatReport (group chat or workspace) use it's pending fields, otherwise indicate that we are adding a chat if (!existingSplitChatReport) { splitChatReport.pendingFields = { @@ -3180,7 +3185,10 @@ function createSplitsAndOnyxData( // and we need the data to be available when we navigate to the chat page onyxMethod: existingSplitChatReport ? Onyx.METHOD.MERGE : Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.REPORT}${splitChatReport.reportID}`, - value: splitChatReport, + value: { + ...splitChatReport, + notificationPreference: splitChatReportNotificationPreference, + }, }, { onyxMethod: Onyx.METHOD.SET, diff --git a/tests/unit/OptionsListUtilsTest.ts b/tests/unit/OptionsListUtilsTest.ts index 7a7930cb5871..76b4324f697b 100644 --- a/tests/unit/OptionsListUtilsTest.ts +++ b/tests/unit/OptionsListUtilsTest.ts @@ -21,6 +21,10 @@ describe('OptionsListUtils', () => { reportID: '1', participantAccountIDs: [2, 1], visibleChatMemberAccountIDs: [2, 1], + participants: { + 2: {}, + 1: {}, + }, reportName: 'Iron Man, Mister Fantastic', type: CONST.REPORT.TYPE.CHAT, }, @@ -31,6 +35,9 @@ describe('OptionsListUtils', () => { reportID: '2', participantAccountIDs: [3], visibleChatMemberAccountIDs: [3], + participants: { + 3: {}, + }, reportName: 'Spider-Man', type: CONST.REPORT.TYPE.CHAT, }, @@ -43,6 +50,9 @@ describe('OptionsListUtils', () => { reportID: '3', participantAccountIDs: [1], visibleChatMemberAccountIDs: [1], + participants: { + 1: {}, + }, reportName: 'Mister Fantastic', type: CONST.REPORT.TYPE.CHAT, }, @@ -53,6 +63,9 @@ describe('OptionsListUtils', () => { reportID: '4', participantAccountIDs: [4], visibleChatMemberAccountIDs: [4], + participants: { + 4: {}, + }, reportName: 'Black Panther', type: CONST.REPORT.TYPE.CHAT, }, @@ -63,6 +76,9 @@ describe('OptionsListUtils', () => { reportID: '5', participantAccountIDs: [5], visibleChatMemberAccountIDs: [5], + participants: { + 5: {}, + }, reportName: 'Invisible Woman', type: CONST.REPORT.TYPE.CHAT, }, @@ -73,6 +89,9 @@ describe('OptionsListUtils', () => { reportID: '6', participantAccountIDs: [6], visibleChatMemberAccountIDs: [6], + participants: { + 6: {}, + }, reportName: 'Thor', type: CONST.REPORT.TYPE.CHAT, }, @@ -85,6 +104,9 @@ describe('OptionsListUtils', () => { reportID: '7', participantAccountIDs: [7], visibleChatMemberAccountIDs: [7], + participants: { + 7: {}, + }, reportName: 'Captain America', type: CONST.REPORT.TYPE.CHAT, }, @@ -97,6 +119,9 @@ describe('OptionsListUtils', () => { reportID: '8', participantAccountIDs: [12], visibleChatMemberAccountIDs: [12], + participants: { + 12: {}, + }, reportName: 'Silver Surfer', type: CONST.REPORT.TYPE.CHAT, }, @@ -109,6 +134,9 @@ describe('OptionsListUtils', () => { reportID: '9', participantAccountIDs: [8], visibleChatMemberAccountIDs: [8], + participants: { + 8: {}, + }, reportName: 'Mister Sinister', iouReportID: '100', type: CONST.REPORT.TYPE.CHAT, @@ -122,6 +150,10 @@ describe('OptionsListUtils', () => { isPinned: false, participantAccountIDs: [2, 7], visibleChatMemberAccountIDs: [2, 7], + participants: { + 2: {}, + 7: {}, + }, reportName: '', oldPolicyName: "SHIELD's workspace", chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, @@ -212,6 +244,9 @@ describe('OptionsListUtils', () => { reportID: '11', participantAccountIDs: [999], visibleChatMemberAccountIDs: [999], + participants: { + 999: {}, + }, reportName: 'Concierge', type: CONST.REPORT.TYPE.CHAT, }, @@ -226,6 +261,9 @@ describe('OptionsListUtils', () => { reportID: '12', participantAccountIDs: [1000], visibleChatMemberAccountIDs: [1000], + participants: { + 1000: {}, + }, reportName: 'Chronos', type: CONST.REPORT.TYPE.CHAT, }, @@ -240,6 +278,9 @@ describe('OptionsListUtils', () => { reportID: '13', participantAccountIDs: [1001], visibleChatMemberAccountIDs: [1001], + participants: { + 1001: {}, + }, reportName: 'Receipts', type: CONST.REPORT.TYPE.CHAT, }, @@ -254,6 +295,11 @@ describe('OptionsListUtils', () => { reportID: '14', participantAccountIDs: [1, 10, 3], visibleChatMemberAccountIDs: [1, 10, 3], + participants: { + 1: {}, + 10: {}, + 3: {}, + }, reportName: '', oldPolicyName: 'Avengers Room', chatType: CONST.REPORT.CHAT_TYPE.POLICY_ADMINS, @@ -271,6 +317,10 @@ describe('OptionsListUtils', () => { reportID: '15', participantAccountIDs: [3, 4], visibleChatMemberAccountIDs: [3, 4], + participants: { + 3: {}, + 4: {}, + }, reportName: 'Spider-Man, Black Panther', type: CONST.REPORT.TYPE.CHAT, chatType: CONST.REPORT.CHAT_TYPE.DOMAIN_ALL,