From 000ebb39b546c59c0d6af2622827100717d96093 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 14 May 2024 16:38:29 +0700 Subject: [PATCH 1/5] Hiden contact option if we don't include P2P option --- 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 f1bdac4a2494..461b25bad1c8 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1827,7 +1827,7 @@ function getOptions( return option; }); - const havingLoginPersonalDetails = options.personalDetails.filter((detail) => !!detail?.login && !!detail.accountID && !detail?.isOptimisticPersonalDetail); + const havingLoginPersonalDetails = includeP2P ? options.personalDetails.filter((detail) => !!detail?.login && !!detail.accountID && !detail?.isOptimisticPersonalDetail) : []; let allPersonalDetailsOptions = havingLoginPersonalDetails; if (sortPersonalDetailsByAlphaAsc) { From b58355787407805c42b5aa7cfc7ee673895eadf1 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 21 May 2024 11:11:12 +0700 Subject: [PATCH 2/5] remove includePersonalDetails --- src/libs/OptionsListUtils.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 223a7fa1a832..eb6233d004f5 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -141,7 +141,6 @@ type GetOptionsConfig = { maxRecentReportsToShow?: number; excludeLogins?: string[]; includeMultipleParticipantReports?: boolean; - includePersonalDetails?: boolean; includeRecentReports?: boolean; includeSelfDM?: boolean; sortByReportTypeInSearch?: boolean; @@ -1648,7 +1647,6 @@ function getOptions( maxRecentReportsToShow = 0, excludeLogins = [], includeMultipleParticipantReports = false, - includePersonalDetails = false, includeRecentReports = false, // When sortByReportTypeInSearch flag is true, recentReports will include the personalDetails options as well. sortByReportTypeInSearch = false, @@ -1917,7 +1915,7 @@ function getOptions( } } - if (includePersonalDetails) { + if (includeP2P) { const personalDetailsOptionsToExclude = [...optionsToExclude, {login: currentUserLogin}]; // Next loop over all personal details removing any that are selectedUsers or recentChats allPersonalDetailsOptions.forEach((personalDetailOption) => { @@ -1990,7 +1988,7 @@ function getSearchOptions(options: OptionList, searchValue = '', betas: Beta[] = maxRecentReportsToShow: 0, // Unlimited sortByReportTypeInSearch: true, showChatPreviewLine: true, - includePersonalDetails: true, + includeP2P: true, forcePolicyNamePreview: true, includeOwnedWorkspaceChats: true, includeThreads: true, @@ -2011,7 +2009,7 @@ function getShareLogOptions(options: OptionList, searchValue = '', betas: Beta[] includeRecentReports: true, includeMultipleParticipantReports: true, sortByReportTypeInSearch: true, - includePersonalDetails: true, + includeP2P: true, forcePolicyNamePreview: true, includeOwnedWorkspaceChats: true, includeSelfDM: true, @@ -2068,7 +2066,6 @@ function getFilteredOptions( includePolicyReportFieldOptions = false, policyReportFieldOptions: string[] = [], recentlyUsedPolicyReportFieldOptions: string[] = [], - includePersonalDetails = true, maxRecentReportsToShow = 5, ) { return getOptions( @@ -2078,7 +2075,6 @@ function getFilteredOptions( searchInputValue: searchValue.trim(), selectedOptions, includeRecentReports: true, - includePersonalDetails, maxRecentReportsToShow, excludeLogins, includeOwnedWorkspaceChats, @@ -2124,7 +2120,7 @@ function getShareDestinationOptions( maxRecentReportsToShow: 0, // Unlimited includeRecentReports: true, includeMultipleParticipantReports: true, - includePersonalDetails: false, + includeP2P: false, showChatPreviewLine: true, forcePolicyNamePreview: true, includeThreads: true, @@ -2181,7 +2177,7 @@ function getMemberInviteOptions( { betas, searchInputValue: searchValue.trim(), - includePersonalDetails: true, + includeP2P: true, excludeLogins, sortPersonalDetailsByAlphaAsc: true, includeSelectedOptions, From 096c21201cc9d5be6a78419b020e64817bb55da2 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 21 May 2024 11:16:02 +0700 Subject: [PATCH 3/5] fix ts --- src/libs/OptionsListUtils.ts | 1 - src/pages/iou/request/MoneyRequestParticipantsSelector.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index eb6233d004f5..0fa0ed1782f9 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -2120,7 +2120,6 @@ function getShareDestinationOptions( maxRecentReportsToShow: 0, // Unlimited includeRecentReports: true, includeMultipleParticipantReports: true, - includeP2P: false, showChatPreviewLine: true, forcePolicyNamePreview: true, includeThreads: true, diff --git a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx index b525a2c1e3dd..2f75c34b3e74 100644 --- a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx +++ b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx @@ -115,7 +115,6 @@ function MoneyRequestParticipantsSelector({participants = [], onFinish, onPartic undefined, undefined, undefined, - !isCategorizeOrShareAction, isCategorizeOrShareAction ? 0 : undefined, ); From 0ff20cac2eaf7c781d1cb01e7fe0506af051441c Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 21 May 2024 11:20:01 +0700 Subject: [PATCH 4/5] fix jest test --- tests/unit/OptionsListUtilsTest.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.ts b/tests/unit/OptionsListUtilsTest.ts index ae8a93efda96..297ec8b00f4f 100644 --- a/tests/unit/OptionsListUtilsTest.ts +++ b/tests/unit/OptionsListUtilsTest.ts @@ -476,6 +476,7 @@ describe('OptionsListUtils', () => { undefined, undefined, undefined, + false, undefined, undefined, undefined, @@ -490,8 +491,6 @@ describe('OptionsListUtils', () => { undefined, undefined, undefined, - undefined, - false, ); // Then no personal detail options will be returned From ecf84585593b826c875897eee4f10ca617778b30 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Wed, 22 May 2024 17:11:35 +0700 Subject: [PATCH 5/5] remove unnecessary condition --- src/libs/OptionsListUtils.ts | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 0fa0ed1782f9..d59c60848c5a 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1915,22 +1915,20 @@ function getOptions( } } - if (includeP2P) { - const personalDetailsOptionsToExclude = [...optionsToExclude, {login: currentUserLogin}]; - // Next loop over all personal details removing any that are selectedUsers or recentChats - allPersonalDetailsOptions.forEach((personalDetailOption) => { - if (personalDetailsOptionsToExclude.some((optionToExclude) => optionToExclude.login === personalDetailOption.login)) { - return; - } - const {searchText, participantsList, isChatRoom} = personalDetailOption; - const participantNames = getParticipantNames(participantsList); - if (searchValue && !isSearchStringMatch(searchValue, searchText, participantNames, isChatRoom)) { - return; - } + const personalDetailsOptionsToExclude = [...optionsToExclude, {login: currentUserLogin}]; + // Next loop over all personal details removing any that are selectedUsers or recentChats + allPersonalDetailsOptions.forEach((personalDetailOption) => { + if (personalDetailsOptionsToExclude.some((optionToExclude) => optionToExclude.login === personalDetailOption.login)) { + return; + } + const {searchText, participantsList, isChatRoom} = personalDetailOption; + const participantNames = getParticipantNames(participantsList); + if (searchValue && !isSearchStringMatch(searchValue, searchText, participantNames, isChatRoom)) { + return; + } - personalDetailsOptions.push(personalDetailOption); - }); - } + personalDetailsOptions.push(personalDetailOption); + }); let currentUserOption = allPersonalDetailsOptions.find((personalDetailsOption) => personalDetailsOption.login === currentUserLogin); if (searchValue && currentUserOption && !isSearchStringMatch(searchValue, currentUserOption.searchText)) {