Skip to content

Commit a10a5dc

Browse files
authored
Merge pull request Expensify#68841 from lorretheboy/fix/67609
Account owner's name is missing in type:chat from: suggestions
2 parents 1fcbc5e + 7e7a70e commit a10a5dc

3 files changed

Lines changed: 31 additions & 1 deletion

File tree

src/components/Search/SearchAutocompleteList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ function SearchAutocompleteList(
346346
case CONST.SEARCH.SYNTAX_FILTER_KEYS.FROM:
347347
case CONST.SEARCH.SYNTAX_FILTER_KEYS.PAYER:
348348
case CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTER: {
349-
const participants = getSearchOptions(options, betas ?? [], true, true, autocompleteValue, 10, false, false).personalDetails.filter(
349+
const participants = getSearchOptions(options, betas ?? [], true, true, autocompleteValue, 10, false, false, true).personalDetails.filter(
350350
(participant) => participant.text && !alreadyAutocompletedKeys.includes(participant.text.toLowerCase()),
351351
);
352352

src/libs/OptionsListUtils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,6 +2077,7 @@ function getSearchOptions(
20772077
maxResults?: number,
20782078
includeUserToInvite?: boolean,
20792079
includeRecentReports = true,
2080+
includeCurrentUser = false,
20802081
): Options {
20812082
Timing.start(CONST.TIMING.LOAD_SEARCH_OPTIONS);
20822083
Performance.markStart(CONST.TIMING.LOAD_SEARCH_OPTIONS);
@@ -2095,6 +2096,7 @@ function getSearchOptions(
20952096
shouldBoldTitleByDefault: !isUsedInChatFinder,
20962097
excludeHiddenThreads: true,
20972098
maxElements: maxResults,
2099+
includeCurrentUser,
20982100
searchString: searchQuery,
20992101
includeUserToInvite,
21002102
});

tests/unit/OptionsListUtilsTest.tsx

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

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

0 commit comments

Comments
 (0)