Skip to content

Commit

Permalink
Merge pull request #44253 from callstack-internal/fix/prevent-display…
Browse files Browse the repository at this point in the history
…ing-email-twice-on-expense

fix: prevent displaying email twice in search when it exists
(cherry picked from commit dc7e22f)
  • Loading branch information
srikarparsi authored and OSBotify committed Jun 24, 2024
1 parent 1c64e17 commit 710b280
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2517,7 +2517,7 @@ function filterOptions(options: Options, searchInputValue: string, config?: Filt

let userToInvite = null;
if (canInviteUser) {
if (recentReports.length === 0) {
if (recentReports.length === 0 && personalDetails.length === 0) {
userToInvite = getUserToInviteOption({
searchValue,
betas,
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/OptionsListUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2938,6 +2938,15 @@ describe('OptionsListUtils', () => {

expect(filteredOptions.recentReports.length).toBe(2);
});

it('should not return any user to invite if email exists on the personal details list', () => {
const searchText = '[email protected]';
const options = OptionsListUtils.getSearchOptions(OPTIONS, '', [CONST.BETAS.ALL]);

const filteredOptions = OptionsListUtils.filterOptions(options, searchText);
expect(filteredOptions.personalDetails.length).toBe(1);
expect(filteredOptions.userToInvite).toBe(null);
});
});

describe('canCreateOptimisticPersonalDetailOption', () => {
Expand Down

0 comments on commit 710b280

Please sign in to comment.