diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 49a88733be5b..9290b0dab722 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, diff --git a/tests/unit/OptionsListUtilsTest.ts b/tests/unit/OptionsListUtilsTest.ts index a08b43c337cb..4a1171658f4d 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', () => {