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
10 changes: 5 additions & 5 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ type GetOptionsConfig = {
includeRecentReports?: boolean;
includeSelectedOptions?: boolean;
recentAttendees?: Attendee[];
excludeHiddenReports?: boolean;
excludeHiddenThreads?: boolean;
canShowManagerMcTest?: boolean;
} & GetValidReportsConfig;

Expand Down Expand Up @@ -1484,7 +1484,7 @@ function getValidOptions(
selectedOptions = [],
shouldSeparateSelfDMChat = false,
shouldSeparateWorkspaceChat = false,
excludeHiddenReports = false,
excludeHiddenThreads = false,
canShowManagerMcTest = false,
...config
}: GetOptionsConfig = {},
Expand Down Expand Up @@ -1579,8 +1579,8 @@ function getValidOptions(
}
}

if (excludeHiddenReports) {
recentReportOptions = recentReportOptions.filter((option) => option.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN);
if (excludeHiddenThreads) {
recentReportOptions = recentReportOptions.filter((option) => !option.isThread || option.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN);
}

return {
Expand Down Expand Up @@ -1613,7 +1613,7 @@ function getSearchOptions(options: OptionList, betas: Beta[] = [], isUsedInChatF
includeTasks: true,
includeSelfDM: true,
shouldBoldTitleByDefault: !isUsedInChatFinder,
excludeHiddenReports: true,
excludeHiddenThreads: true,
});
const orderedOptions = orderOptions(optionList);
Timing.end(CONST.TIMING.LOAD_SEARCH_OPTIONS);
Expand Down
35 changes: 26 additions & 9 deletions tests/unit/OptionsListUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,24 @@ describe('OptionsListUtils', () => {
isOwnPolicyExpenseChat: true,
type: CONST.REPORT.TYPE.CHAT,
},
'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: '',
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
isOwnPolicyExpenseChat: true,
type: CONST.REPORT.TYPE.CHAT,
policyID,
policyName: POLICY.name,
},

// Thread report with notification preference = hidden
'11': {
'12': {
lastReadTime: '2021-01-14 11:25:39.200',
lastVisibleActionCreated: '2022-11-22 03:26:02.001',
reportID: '11',
Expand All @@ -195,6 +210,8 @@ describe('OptionsListUtils', () => {
type: CONST.REPORT.TYPE.CHAT,
policyID,
policyName: POLICY.name,
parentReportActionID: '123',
parentReportID: '123',
},
};

Expand Down Expand Up @@ -547,7 +564,7 @@ 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, except for the report with notificationPreferences hidden.
// Then all of the reports should be shown including the archived rooms, except for the thread report with notificationPreferences hidden.
expect(results.recentReports.length).toBe(Object.values(OPTIONS.reports).length - 1);
});

Expand Down Expand Up @@ -766,8 +783,8 @@ describe('OptionsListUtils', () => {
// When we pass an empty search value
let results = getShareDestinationOptions(filteredReports, OPTIONS.personalDetails, []);

// Then we should expect all the recent reports to show but exclude the archived rooms
expect(results.recentReports.length).toBe(Object.values(OPTIONS.reports).length - 1);
// Then we should expect all the recent reports to show but exclude the archived rooms and the hidden thread
expect(results.recentReports.length).toBe(Object.values(OPTIONS.reports).length - 2);

// Filter current REPORTS_WITH_WORKSPACE_ROOMS as we do in the component, before getting share destination options
const filteredReportsWithWorkspaceRooms = Object.values(OPTIONS_WITH_WORKSPACE_ROOM.reports).reduce<OptionList['reports']>((filtered, option) => {
Expand All @@ -782,8 +799,8 @@ describe('OptionsListUtils', () => {
// When we also have a policy to return rooms in the results
results = getShareDestinationOptions(filteredReportsWithWorkspaceRooms, OPTIONS.personalDetails, []);
// Then we should expect the DMS, the group chats and the workspace room to show
// We should expect all the recent reports to show, excluding the archived rooms
expect(results.recentReports.length).toBe(Object.values(OPTIONS_WITH_WORKSPACE_ROOM.reports).length - 1);
// We should expect all the recent reports to show, excluding the archived rooms and the hidden thread
expect(results.recentReports.length).toBe(Object.values(OPTIONS_WITH_WORKSPACE_ROOM.reports).length - 2);
});

describe('getShareLogOptions', () => {
Expand Down Expand Up @@ -834,7 +851,7 @@ describe('OptionsListUtils', () => {
const options = getSearchOptions(OPTIONS, [CONST.BETAS.ALL]);
const filteredOptions = filterAndOrderOptions(options, '');

expect(filteredOptions.recentReports.length + filteredOptions.personalDetails.length).toBe(12);
expect(filteredOptions.recentReports.length + filteredOptions.personalDetails.length).toBe(13);
});

it('should return filtered options in correct order', () => {
Expand Down Expand Up @@ -923,7 +940,7 @@ describe('OptionsListUtils', () => {
const options = getSearchOptions(OPTIONS);
const filteredOptions = filterAndOrderOptions(options, searchText);

expect(filteredOptions.recentReports.length).toBe(2);
expect(filteredOptions.recentReports.length).toBe(3);
expect(filteredOptions.recentReports.at(0)?.text).toBe('Mister Fantastic');
expect(filteredOptions.recentReports.at(1)?.text).toBe('Mister Fantastic, Invisible Woman');
});
Expand Down Expand Up @@ -1151,7 +1168,7 @@ describe('OptionsListUtils', () => {
const options = getSearchOptions(OPTIONS);
const filteredOptions = filterAndOrderOptions(options, 'fantastic');

expect(filteredOptions.recentReports.length).toBe(2);
expect(filteredOptions.recentReports.length).toBe(3);
expect(filteredOptions.recentReports.at(0)?.text).toBe('Mister Fantastic');
expect(filteredOptions.recentReports.at(1)?.text).toBe('Mister Fantastic, Invisible Woman');

Expand Down