Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ type GetOptionsConfig = {
recentAttendees?: Attendee[];
shouldSeparateWorkspaceChat?: boolean;
shouldSeparateSelfDMChat?: boolean;
excludeHiddenReports?: boolean;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luacmartins Possible to add a unit test for the flag?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated tests to cover this case

} & GetValidReportsConfig;

type GetUserToInviteConfig = {
Expand Down Expand Up @@ -1420,6 +1421,7 @@ function getValidOptions(
selectedOptions = [],
shouldSeparateSelfDMChat = false,
shouldSeparateWorkspaceChat = false,
excludeHiddenReports = false,
...config
}: GetOptionsConfig = {},
): Options {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
20 changes: 18 additions & 2 deletions tests/unit/OptionsListUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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()', () => {
Expand Down