diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index a8e23888db0d..55f08aebff91 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -204,6 +204,7 @@ type GetOptionsConfig = { recentAttendees?: Attendee[]; shouldSeparateWorkspaceChat?: boolean; shouldSeparateSelfDMChat?: boolean; + excludeHiddenReports?: boolean; } & GetValidReportsConfig; type GetUserToInviteConfig = { @@ -1420,6 +1421,7 @@ function getValidOptions( selectedOptions = [], shouldSeparateSelfDMChat = false, shouldSeparateWorkspaceChat = false, + excludeHiddenReports = false, ...config }: GetOptionsConfig = {}, ): Options { @@ -1513,6 +1515,10 @@ function getValidOptions( recentReportOptions = recentReportOptions.filter((option) => !option.isSelfDM); } + if (excludeHiddenReports) { + recentReportOptions = recentReportOptions.filter((option) => option.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN); + } + return { personalDetails: personalDetailsOptions, recentReports: recentReportOptions, @@ -1543,6 +1549,7 @@ function getSearchOptions(options: OptionList, betas: Beta[] = [], isUsedInChatF includeTasks: true, includeSelfDM: true, shouldBoldTitleByDefault: !isUsedInChatFinder, + excludeHiddenReports: true, }); const orderedOptions = orderOptions(optionList); Timing.end(CONST.TIMING.LOAD_SEARCH_OPTIONS); diff --git a/tests/unit/OptionsListUtilsTest.ts b/tests/unit/OptionsListUtilsTest.ts index 19ebf261bd7a..bff34a5bad2c 100644 --- a/tests/unit/OptionsListUtilsTest.ts +++ b/tests/unit/OptionsListUtilsTest.ts @@ -149,6 +149,22 @@ describe('OptionsListUtils', () => { isOwnPolicyExpenseChat: true, type: CONST.REPORT.TYPE.CHAT, }, + + // Thread report with notification preference = hidden + '11': { + lastReadTime: '2021-01-14 11:25:39.200', + lastVisibleActionCreated: '2022-11-22 03:26:02.001', + reportID: '11', + isPinned: false, + participants: { + 10: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN}, + }, + reportName: '', + oldPolicyName: "SHIELD's workspace", + chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, + isOwnPolicyExpenseChat: true, + type: CONST.REPORT.TYPE.CHAT, + }, }; const activePolicyID = 'DEF456'; @@ -474,8 +490,8 @@ describe('OptionsListUtils', () => { // Filtering of personalDetails that have reports is done in filterOptions expect(results.personalDetails.length).toBe(9); - // Then all of the reports should be shown including the archived rooms. - expect(results.recentReports.length).toBe(Object.values(OPTIONS.reports).length); + // Then all of the reports should be shown including the archived rooms, except for the report with notificationPreferences hidden. + expect(results.recentReports.length).toBe(Object.values(OPTIONS.reports).length - 1); }); it('orderOptions()', () => {