Skip to content

Commit 7e7a70e

Browse files
committed
fix: addressed comments
1 parent 5f76e42 commit 7e7a70e

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

src/libs/OptionsListUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2073,7 +2073,7 @@ function getSearchOptions(
20732073
maxResults?: number,
20742074
includeUserToInvite?: boolean,
20752075
includeRecentReports = true,
2076-
includeCurrentUser?: boolean,
2076+
includeCurrentUser = false,
20772077
): Options {
20782078
Timing.start(CONST.TIMING.LOAD_SEARCH_OPTIONS);
20792079
Performance.markStart(CONST.TIMING.LOAD_SEARCH_OPTIONS);

tests/unit/OptionsListUtilsTest.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,34 @@ describe('OptionsListUtils', () => {
616616
// Then all of the reports should be shown including the archived rooms, except for the thread report with notificationPreferences hidden.
617617
expect(results.recentReports.length).toBe(Object.values(OPTIONS.reports).length - 1);
618618
});
619+
620+
it('should include current user when includeCurrentUser is true for type:chat from suggestions', () => {
621+
// Given a set of options where the current user is Iron Man (accountID: 2)
622+
// When we call getSearchOptions with includeCurrentUser set to true
623+
const results = getSearchOptions(OPTIONS, [CONST.BETAS.ALL], true, true, '', undefined, false, true, true);
624+
625+
// Then the current user should be included in personalDetails
626+
const currentUserOption = results.personalDetails.find((option) => option.login === 'tonystark@expensify.com');
627+
expect(currentUserOption).toBeDefined();
628+
expect(currentUserOption?.text).toBe('Iron Man');
629+
expect(currentUserOption?.accountID).toBe(2);
630+
631+
// Then all personal details including the current user should be returned
632+
expect(results.personalDetails.length).toBe(10);
633+
});
634+
635+
it('should exclude current user when includeCurrentUser is false', () => {
636+
// Given a set of options where the current user is Iron Man (accountID: 2)
637+
// When we call getSearchOptions with includeCurrentUser set to false (default behavior)
638+
const results = getSearchOptions(OPTIONS, [CONST.BETAS.ALL], true, true, '', undefined, false, true, false);
639+
640+
// Then the current user should not be included in personalDetails
641+
const currentUserOption = results.personalDetails.find((option) => option.login === 'tonystark@expensify.com');
642+
expect(currentUserOption).toBeUndefined();
643+
644+
// Then all personal details except the current user should be returned
645+
expect(results.personalDetails.length).toBe(9);
646+
});
619647
});
620648

621649
describe('orderOptions()', () => {

0 commit comments

Comments
 (0)