From 4d57c9d909c3ba103fec4e7c374f837547acea06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucien=20Akchot=C3=A9?= Date: Thu, 18 Dec 2025 16:10:47 +0100 Subject: [PATCH 1/7] add `shouldAcceptName` to `GetOptionsConfig` type --- src/libs/OptionsListUtils/types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/OptionsListUtils/types.ts b/src/libs/OptionsListUtils/types.ts index c13b856af8bfb..c8c03f52a864d 100644 --- a/src/libs/OptionsListUtils/types.ts +++ b/src/libs/OptionsListUtils/types.ts @@ -190,6 +190,7 @@ type GetOptionsConfig = { maxElements?: number; maxRecentReportElements?: number; includeUserToInvite?: boolean; + shouldAcceptName?: boolean; } & GetValidReportsConfig; type GetUserToInviteConfig = { From 0a5893285a3953750584acb0d553d63988221a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucien=20Akchot=C3=A9?= Date: Thu, 18 Dec 2025 16:11:03 +0100 Subject: [PATCH 2/7] pass `shouldAcceptName` to `filterUserToInvite()` --- src/libs/OptionsListUtils/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 08cfe6e4b4bcb..7b8f7e39f132d 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -2086,6 +2086,7 @@ function getValidOptions( maxElements, includeUserToInvite = false, maxRecentReportElements = undefined, + shouldAcceptName = false, ...config }: GetOptionsConfig = {}, countryCode: number = CONST.DEFAULT_COUNTRY_CODE, @@ -2271,6 +2272,7 @@ function getValidOptions( countryCode, { excludeLogins: loginsToExclude, + shouldAcceptName, }, ); } From b2ee3f8158e48e365e8318d16ab69cdd59be819f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucien=20Akchot=C3=A9?= Date: Thu, 18 Dec 2025 16:11:14 +0100 Subject: [PATCH 3/7] enable `shouldAcceptName` for attendees context --- src/hooks/useSearchSelector.base.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hooks/useSearchSelector.base.ts b/src/hooks/useSearchSelector.base.ts index 2295ba794f5cb..2fdd9fd33ee36 100644 --- a/src/hooks/useSearchSelector.base.ts +++ b/src/hooks/useSearchSelector.base.ts @@ -268,6 +268,7 @@ function useSearchSelectorBase({ searchString: computedSearchTerm, includeUserToInvite, includeCurrentUser, + shouldAcceptName: true, }); default: return getEmptyOptions(); From 44759dcacea047d99a16728079bf48324c64385a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucien=20Akchot=C3=A9?= Date: Thu, 18 Dec 2025 16:56:09 +0100 Subject: [PATCH 4/7] add test --- tests/unit/OptionsListUtilsTest.tsx | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/unit/OptionsListUtilsTest.tsx b/tests/unit/OptionsListUtilsTest.tsx index e597953bed302..8bef248545eda 100644 --- a/tests/unit/OptionsListUtilsTest.tsx +++ b/tests/unit/OptionsListUtilsTest.tsx @@ -1940,6 +1940,36 @@ describe('OptionsListUtils', () => { expect(filteredOptions.userToInvite).toBe(null); }); + it('should not return userToInvite for plain text name when shouldAcceptName is false', () => { + // Given a set of options + const options = getValidOptions( + {reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, + {}, + nvpDismissedProductTraining, + {includeUserToInvite: true}, + ); + // When we call filterAndOrderOptions with a plain text name (not email or phone) without shouldAcceptName + const filteredOptions = filterAndOrderOptions(options, 'Jeff Amazon', COUNTRY_CODE, {shouldAcceptName: false}); + + // Then userToInvite should be null since plain names are not accepted by default + expect(filteredOptions?.userToInvite).toBe(null); + }); + + it('should return userToInvite for plain text name when shouldAcceptName is true', () => { + // Given a set of options + const options = getValidOptions( + {reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, + {}, + nvpDismissedProductTraining, + {includeUserToInvite: true}, + ); + // When we call filterAndOrderOptions with a plain text name (not email or phone) with shouldAcceptName + const filteredOptions = filterAndOrderOptions(options, 'Jeff', COUNTRY_CODE, {shouldAcceptName: true}); + + // Then userToInvite should be returned for the plain name + expect(filteredOptions?.userToInvite?.text).toBe('jeff'); + }); + it('should not return any options if search value does not match any personal details', () => { // Given a set of options const options = getValidOptions({reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, {}, nvpDismissedProductTraining); From f7687db97f15d29a4c18e8826fde0cd39141f768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucien=20Akchot=C3=A9?= Date: Thu, 18 Dec 2025 16:57:44 +0100 Subject: [PATCH 5/7] fix style --- tests/unit/OptionsListUtilsTest.tsx | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.tsx b/tests/unit/OptionsListUtilsTest.tsx index 8bef248545eda..1fc58e524c69c 100644 --- a/tests/unit/OptionsListUtilsTest.tsx +++ b/tests/unit/OptionsListUtilsTest.tsx @@ -1942,12 +1942,7 @@ describe('OptionsListUtils', () => { it('should not return userToInvite for plain text name when shouldAcceptName is false', () => { // Given a set of options - const options = getValidOptions( - {reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, - {}, - nvpDismissedProductTraining, - {includeUserToInvite: true}, - ); + const options = getValidOptions({reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, {}, nvpDismissedProductTraining, {includeUserToInvite: true}); // When we call filterAndOrderOptions with a plain text name (not email or phone) without shouldAcceptName const filteredOptions = filterAndOrderOptions(options, 'Jeff Amazon', COUNTRY_CODE, {shouldAcceptName: false}); @@ -1957,12 +1952,7 @@ describe('OptionsListUtils', () => { it('should return userToInvite for plain text name when shouldAcceptName is true', () => { // Given a set of options - const options = getValidOptions( - {reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, - {}, - nvpDismissedProductTraining, - {includeUserToInvite: true}, - ); + const options = getValidOptions({reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, {}, nvpDismissedProductTraining, {includeUserToInvite: true}); // When we call filterAndOrderOptions with a plain text name (not email or phone) with shouldAcceptName const filteredOptions = filterAndOrderOptions(options, 'Jeff', COUNTRY_CODE, {shouldAcceptName: true}); From c5d8ead26e26ed94a0a5b2cb8d3fa91994493281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucien=20Akchot=C3=A9?= Date: Thu, 18 Dec 2025 18:26:31 +0100 Subject: [PATCH 6/7] Update tests/unit/OptionsListUtilsTest.tsx Co-authored-by: Vit Horacek <36083550+mountiny@users.noreply.github.com> --- tests/unit/OptionsListUtilsTest.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/OptionsListUtilsTest.tsx b/tests/unit/OptionsListUtilsTest.tsx index 1fc58e524c69c..a8dce34af3e2d 100644 --- a/tests/unit/OptionsListUtilsTest.tsx +++ b/tests/unit/OptionsListUtilsTest.tsx @@ -1953,6 +1953,7 @@ describe('OptionsListUtils', () => { it('should return userToInvite for plain text name when shouldAcceptName is true', () => { // Given a set of options const options = getValidOptions({reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, {}, nvpDismissedProductTraining, {includeUserToInvite: true}); + // When we call filterAndOrderOptions with a plain text name (not email or phone) with shouldAcceptName const filteredOptions = filterAndOrderOptions(options, 'Jeff', COUNTRY_CODE, {shouldAcceptName: true}); From c2a4b5c14c0414d1dbd0d557421ee7482f65db2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucien=20Akchot=C3=A9?= Date: Thu, 18 Dec 2025 18:26:49 +0100 Subject: [PATCH 7/7] Update tests/unit/OptionsListUtilsTest.tsx Co-authored-by: Vit Horacek <36083550+mountiny@users.noreply.github.com> --- tests/unit/OptionsListUtilsTest.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/OptionsListUtilsTest.tsx b/tests/unit/OptionsListUtilsTest.tsx index a8dce34af3e2d..c5911c57b7f5e 100644 --- a/tests/unit/OptionsListUtilsTest.tsx +++ b/tests/unit/OptionsListUtilsTest.tsx @@ -1943,6 +1943,7 @@ describe('OptionsListUtils', () => { it('should not return userToInvite for plain text name when shouldAcceptName is false', () => { // Given a set of options const options = getValidOptions({reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, {}, nvpDismissedProductTraining, {includeUserToInvite: true}); + // When we call filterAndOrderOptions with a plain text name (not email or phone) without shouldAcceptName const filteredOptions = filterAndOrderOptions(options, 'Jeff Amazon', COUNTRY_CODE, {shouldAcceptName: false});