diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index d2c0022e3d03..a7c65df7dd03 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -144,7 +144,6 @@ type GetOptionsConfig = { maxRecentReportsToShow?: number; excludeLogins?: string[]; includeMultipleParticipantReports?: boolean; - includePersonalDetails?: boolean; includeRecentReports?: boolean; includeSelfDM?: boolean; sortByReportTypeInSearch?: boolean; @@ -1698,7 +1697,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, @@ -1888,7 +1886,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) { @@ -1974,22 +1972,20 @@ function getOptions( } } - if (includePersonalDetails) { - 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)) { @@ -2047,7 +2043,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, @@ -2068,7 +2064,7 @@ function getShareLogOptions(options: OptionList, searchValue = '', betas: Beta[] includeRecentReports: true, includeMultipleParticipantReports: true, sortByReportTypeInSearch: true, - includePersonalDetails: true, + includeP2P: true, forcePolicyNamePreview: true, includeOwnedWorkspaceChats: true, includeSelfDM: true, @@ -2125,7 +2121,6 @@ function getFilteredOptions( includePolicyReportFieldOptions = false, policyReportFieldOptions: string[] = [], recentlyUsedPolicyReportFieldOptions: string[] = [], - includePersonalDetails = true, maxRecentReportsToShow = 5, ) { return getOptions( @@ -2135,7 +2130,6 @@ function getFilteredOptions( searchInputValue: searchValue.trim(), selectedOptions, includeRecentReports: true, - includePersonalDetails, maxRecentReportsToShow, excludeLogins, includeOwnedWorkspaceChats, @@ -2181,7 +2175,6 @@ function getShareDestinationOptions( maxRecentReportsToShow: 0, // Unlimited includeRecentReports: true, includeMultipleParticipantReports: true, - includePersonalDetails: false, showChatPreviewLine: true, forcePolicyNamePreview: true, includeThreads: true, @@ -2238,7 +2231,7 @@ function getMemberInviteOptions( { betas, searchInputValue: searchValue.trim(), - includePersonalDetails: true, + includeP2P: true, excludeLogins, sortPersonalDetailsByAlphaAsc: true, includeSelectedOptions, diff --git a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx index 1d9aec1ea60d..1e8e63ee2df3 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, ); diff --git a/tests/unit/OptionsListUtilsTest.ts b/tests/unit/OptionsListUtilsTest.ts index bcb569ba4490..59fc3c9b3a12 100644 --- a/tests/unit/OptionsListUtilsTest.ts +++ b/tests/unit/OptionsListUtilsTest.ts @@ -477,6 +477,7 @@ describe('OptionsListUtils', () => { undefined, undefined, undefined, + false, undefined, undefined, undefined, @@ -491,8 +492,6 @@ describe('OptionsListUtils', () => { undefined, undefined, undefined, - undefined, - false, ); // Then no personal detail options will be returned