From 898771d735903bb67120a9b02da78f2b4ea001da Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Mon, 24 Jun 2024 13:48:34 +0200 Subject: [PATCH 1/2] fix: prevent displaying email twice in search when it exists --- src/libs/OptionsListUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 49a88733be5ba..9290b0dab7228 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -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, From 20cba0df48568795610f272b21f0ff07130cc345 Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Mon, 24 Jun 2024 15:03:12 +0200 Subject: [PATCH 2/2] add test for userToInvite --- tests/unit/OptionsListUtilsTest.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/unit/OptionsListUtilsTest.ts b/tests/unit/OptionsListUtilsTest.ts index a08b43c337cb6..4a1171658f4d6 100644 --- a/tests/unit/OptionsListUtilsTest.ts +++ b/tests/unit/OptionsListUtilsTest.ts @@ -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 = 'natasharomanoff@expensify.com'; + 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', () => {