Skip to content

Commit 710b280

Browse files
srikarparsiOSBotify
authored andcommitted
Merge pull request #44253 from callstack-internal/fix/prevent-displaying-email-twice-on-expense
fix: prevent displaying email twice in search when it exists (cherry picked from commit dc7e22f)
1 parent 1c64e17 commit 710b280

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/libs/OptionsListUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2517,7 +2517,7 @@ function filterOptions(options: Options, searchInputValue: string, config?: Filt
25172517

25182518
let userToInvite = null;
25192519
if (canInviteUser) {
2520-
if (recentReports.length === 0) {
2520+
if (recentReports.length === 0 && personalDetails.length === 0) {
25212521
userToInvite = getUserToInviteOption({
25222522
searchValue,
25232523
betas,

tests/unit/OptionsListUtilsTest.ts

+9
Original file line numberDiff line numberDiff line change
@@ -2938,6 +2938,15 @@ describe('OptionsListUtils', () => {
29382938

29392939
expect(filteredOptions.recentReports.length).toBe(2);
29402940
});
2941+
2942+
it('should not return any user to invite if email exists on the personal details list', () => {
2943+
const searchText = 'natasharomanoff@expensify.com';
2944+
const options = OptionsListUtils.getSearchOptions(OPTIONS, '', [CONST.BETAS.ALL]);
2945+
2946+
const filteredOptions = OptionsListUtils.filterOptions(options, searchText);
2947+
expect(filteredOptions.personalDetails.length).toBe(1);
2948+
expect(filteredOptions.userToInvite).toBe(null);
2949+
});
29412950
});
29422951

29432952
describe('canCreateOptimisticPersonalDetailOption', () => {

0 commit comments

Comments
 (0)