From 5d89c621b384363043e6d4998a374fe3c8e56177 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 30 Jan 2025 14:44:44 -0700 Subject: [PATCH 1/2] exclude hidden reports --- src/libs/OptionsListUtils.ts | 7 +++++++ 1 file changed, 7 insertions(+) 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); From 50ff162c1e74b865ee778473e643f1227a66037e Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 3 Feb 2025 11:00:18 -0800 Subject: [PATCH 2/2] add test --- tests/unit/OptionsListUtilsTest.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) 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()', () => {