diff --git a/src/components/Search/FilterDropdowns/InSelectPopup.tsx b/src/components/Search/FilterDropdowns/InSelectPopup.tsx index ae29a78d9e8c..c0374fd18df5 100644 --- a/src/components/Search/FilterDropdowns/InSelectPopup.tsx +++ b/src/components/Search/FilterDropdowns/InSelectPopup.tsx @@ -71,6 +71,7 @@ function InSelectPopup({closeOverlay, updateFilterForm}: InSelectPopupProps) { const privateIsArchivedMap = usePrivateIsArchivedMap(); const [nvpDismissedProductTraining] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING); const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {selector: passthroughPolicyTagListSelector}); + const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); const selectedOptions: OptionData[] = selectedReportIDs.map((id) => { const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${id}`]; @@ -80,7 +81,7 @@ function InSelectPopup({closeOverlay, updateFilterForm}: InSelectPopupProps) { const isReportArchived = !!privateIsArchived; const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${reportData?.policyID}`]; const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${getNonEmptyStringOnyxID(report?.policyID)}`]; - const alternateText = getAlternateText(report, {}, {isReportArchived, policy, reportAttributesDerived, policyTags: reportPolicyTags}); + const alternateText = getAlternateText(report, {}, {isReportArchived, policy, reportAttributesDerived, policyTags: reportPolicyTags, conciergeReportID}); return {...report, alternateText}; }); diff --git a/src/components/Search/SearchFiltersChatsSelector.tsx b/src/components/Search/SearchFiltersChatsSelector.tsx index 3f8fc264fbd9..2d11924c8199 100644 --- a/src/components/Search/SearchFiltersChatsSelector.tsx +++ b/src/components/Search/SearchFiltersChatsSelector.tsx @@ -54,6 +54,7 @@ function SearchFiltersChatsSelector({initialReportIDs, onFiltersUpdate, isScreen const [countryCode = CONST.DEFAULT_COUNTRY_CODE] = useOnyx(ONYXKEYS.COUNTRY_CODE); const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST); const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY); + const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const currentUserAccountID = currentUserPersonalDetails.accountID; const currentUserEmail = currentUserPersonalDetails.email ?? ''; @@ -75,7 +76,7 @@ function SearchFiltersChatsSelector({initialReportIDs, onFiltersUpdate, isScreen const report = getSelectedOptionData(createOptionFromReport({...reportData, reportID: id}, personalDetails, privateIsArchived, reportPolicy, reportAttributesDerived)); const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${reportData?.policyID}`]; const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${getNonEmptyStringOnyxID(report?.policyID)}`]; - const alternateText = getAlternateText(report, {}, {isReportArchived: privateIsArchived, policy, reportAttributesDerived, policyTags: reportPolicyTags}); + const alternateText = getAlternateText(report, {}, {isReportArchived: privateIsArchived, policy, reportAttributesDerived, policyTags: reportPolicyTags, conciergeReportID}); return {...report, alternateText}; }); diff --git a/src/hooks/useSearchSelector.base.ts b/src/hooks/useSearchSelector.base.ts index 33901dc93cfb..137cdd777df2 100644 --- a/src/hooks/useSearchSelector.base.ts +++ b/src/hooks/useSearchSelector.base.ts @@ -201,6 +201,7 @@ function useSearchSelectorBase({ const currentUserEmail = currentUserPersonalDetails.email ?? ''; const personalDetails = usePersonalDetails(); const [allPolicyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {selector: passthroughPolicyTagListSelector}); + const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); const onListEndReached = useDebounce( useCallback(() => { @@ -240,7 +241,7 @@ function useSearchSelectorBase({ personalDetails, }); case CONST.SEARCH_SELECTOR.SEARCH_CONTEXT_MEMBER_INVITE: - return getValidOptions(optionsWithContacts, allPolicies, draftComments, nvpDismissedProductTraining, loginList, currentUserAccountID, currentUserEmail, { + return getValidOptions(optionsWithContacts, allPolicies, draftComments, nvpDismissedProductTraining, loginList, currentUserAccountID, currentUserEmail, conciergeReportID, { betas: betas ?? [], includeP2P: true, includeSelectedOptions: false, @@ -261,7 +262,7 @@ function useSearchSelectorBase({ sortedActions, }); case CONST.SEARCH_SELECTOR.SEARCH_CONTEXT_GENERAL: - return getValidOptions(optionsWithContacts, allPolicies, draftComments, nvpDismissedProductTraining, loginList, currentUserAccountID, currentUserEmail, { + return getValidOptions(optionsWithContacts, allPolicies, draftComments, nvpDismissedProductTraining, loginList, currentUserAccountID, currentUserEmail, conciergeReportID, { betas: betas ?? [], searchString: computedSearchTerm, searchInputValue: trimmedSearchInput, @@ -284,7 +285,7 @@ function useSearchSelectorBase({ ...getValidOptionsConfig, }); case CONST.SEARCH_SELECTOR.SEARCH_CONTEXT_SHARE_DESTINATION: - return getValidOptions(optionsWithContacts, allPolicies, draftComments, nvpDismissedProductTraining, loginList, currentUserAccountID, currentUserEmail, { + return getValidOptions(optionsWithContacts, allPolicies, draftComments, nvpDismissedProductTraining, loginList, currentUserAccountID, currentUserEmail, conciergeReportID, { betas, selectedOptions, includeMultipleParticipantReports: true, @@ -308,7 +309,7 @@ function useSearchSelectorBase({ sortedActions, }); case CONST.SEARCH_SELECTOR.SEARCH_CONTEXT_ATTENDEES: - return getValidOptions(optionsWithContacts, allPolicies, draftComments, nvpDismissedProductTraining, loginList, currentUserAccountID, currentUserEmail, { + return getValidOptions(optionsWithContacts, allPolicies, draftComments, nvpDismissedProductTraining, loginList, currentUserAccountID, currentUserEmail, conciergeReportID, { betas: betas ?? [], includeP2P: true, includeSelectedOptions: false, @@ -348,6 +349,7 @@ function useSearchSelectorBase({ loginList, currentUserAccountID, currentUserEmail, + conciergeReportID, personalDetails, excludeLogins, excludeFromSuggestionsOnly, diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index a73d04680fb2..1d3aab7128d5 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -438,6 +438,7 @@ type GetAlternateTextConfig = { translate?: LocalizedTranslate; reportAttributesDerived?: ReportAttributesDerivedValue['reports']; policyTags?: OnyxEntry; + conciergeReportID: string | undefined; }; /** @@ -446,7 +447,7 @@ type GetAlternateTextConfig = { function getAlternateText( option: OptionData, {showChatPreviewLine = false, forcePolicyNamePreview = false}: PreviewConfig, - {isReportArchived, policy, lastActorDetails = {}, visibleReportActionsData = {}, translate, reportAttributesDerived, policyTags}: GetAlternateTextConfig, + {isReportArchived, policy, lastActorDetails = {}, visibleReportActionsData = {}, translate, reportAttributesDerived, policyTags, conciergeReportID}: GetAlternateTextConfig, ) { const report = getReportOrDraftReport(option.reportID); const isAdminRoom = reportUtilsIsAdminRoom(report); @@ -466,6 +467,7 @@ function getAlternateText( visibleReportActionsDataParam: visibleReportActionsData, reportAttributesDerived, policyTags, + conciergeReportID, }); const reportPrefix = getReportSubtitlePrefix(report); const formattedLastMessageTextWithPrefix = reportPrefix + formattedLastMessageText; @@ -1106,6 +1108,7 @@ function createOption({ translate: translateFn, reportAttributesDerived, policyTags, + conciergeReportID, }, ); @@ -2269,6 +2272,7 @@ function prepareReportOptionsForDisplay( policiesCollection: OnyxCollection, currentUserAccountID: number, config: GetValidReportsConfig, + conciergeReportID: string | undefined, visibleReportActionsData: VisibleReportActionsDerivedValue = {}, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], // eslint-disable-next-line @typescript-eslint/no-deprecated @@ -2316,6 +2320,7 @@ function prepareReportOptionsForDisplay( visibleReportActionsData, reportAttributesDerived, policyTags: reportPolicyTags, + conciergeReportID, }, ); const isSelected = isReportSelected(option, selectedOptions); @@ -2438,6 +2443,7 @@ function getValidOptions( loginList: OnyxEntry, currentUserAccountID: number, currentUserEmail: string, + conciergeReportID: string | undefined, { excludeLogins = {}, excludeFromSuggestionsOnly = {}, @@ -2564,6 +2570,7 @@ function getValidOptions( shouldShowGBR, personalDetails, }, + conciergeReportID, visibleReportActionsData, reportAttributesDerived, sortedActions, @@ -2587,6 +2594,7 @@ function getValidOptions( shouldShowGBR, personalDetails, }, + conciergeReportID, visibleReportActionsData, reportAttributesDerived, sortedActions, @@ -2606,6 +2614,7 @@ function getValidOptions( shouldShowGBR, personalDetails, }, + conciergeReportID, visibleReportActionsData, reportAttributesDerived, sortedActions, @@ -2765,7 +2774,8 @@ function getSearchOptions({ personalDetails, allPolicyTags, }: SearchOptionsConfig): Options { - const optionList = getValidOptions(options, policyCollection, draftComments, nvpDismissedProductTraining, loginList, currentUserAccountID, currentUserEmail, { + // TODO: We'll pass the conciergeReportID eventually. Refactor issue: https://github.com/Expensify/App/issues/66411 + const optionList = getValidOptions(options, policyCollection, draftComments, nvpDismissedProductTraining, loginList, currentUserAccountID, currentUserEmail, undefined, { betas, includeRecentReports, includeMultipleParticipantReports: true, diff --git a/src/pages/NewChatPage.tsx b/src/pages/NewChatPage.tsx index d80ab7d7d46b..f70cf97df231 100755 --- a/src/pages/NewChatPage.tsx +++ b/src/pages/NewChatPage.tsx @@ -78,6 +78,7 @@ function useOptions(reportAttributesDerived: ReportAttributesDerivedValue['repor const isScreenFocusedRef = useIsFocusedRef(); const [sortedActions] = useOnyx(ONYXKEYS.DERIVED.RAM_ONLY_SORTED_REPORT_ACTIONS, {selector: sortedActionsSelector}); const [allPolicyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {selector: passthroughPolicyTagListSelector}); + const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); const { options: listOptions, @@ -111,6 +112,7 @@ function useOptions(reportAttributesDerived: ReportAttributesDerivedValue['repor loginList, currentUserAccountID, currentUserEmail, + conciergeReportID, { betas: betas ?? [], includeSelfDM: true, diff --git a/src/pages/iou/request/MoneyRequestAccountantSelector.tsx b/src/pages/iou/request/MoneyRequestAccountantSelector.tsx index 3b427160995f..17e95ed4270f 100644 --- a/src/pages/iou/request/MoneyRequestAccountantSelector.tsx +++ b/src/pages/iou/request/MoneyRequestAccountantSelector.tsx @@ -72,6 +72,7 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType const currentUserEmail = currentUserPersonalDetails.email ?? ''; const currentUserAccountID = currentUserPersonalDetails.accountID; const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY); + const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); const privateIsArchivedMap = usePrivateIsArchivedMap(); useEffect(() => { @@ -94,6 +95,7 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType loginList, currentUserAccountID, currentUserEmail, + conciergeReportID, { betas, excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT, @@ -123,6 +125,7 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType countryCode, currentUserAccountID, currentUserEmail, + conciergeReportID, personalDetails, ]); diff --git a/tests/perf-test/OptionsListUtils.perf-test.ts b/tests/perf-test/OptionsListUtils.perf-test.ts index 07e9c0cb3f96..a64cb4db02a9 100644 --- a/tests/perf-test/OptionsListUtils.perf-test.ts +++ b/tests/perf-test/OptionsListUtils.perf-test.ts @@ -156,6 +156,7 @@ describe('OptionsListUtils', () => { loginList, MOCK_CURRENT_USER_ACCOUNT_ID, MOCK_CURRENT_USER_EMAIL, + undefined, ValidOptionsConfig, ); await measureFunction(() => { @@ -172,6 +173,7 @@ describe('OptionsListUtils', () => { loginList, MOCK_CURRENT_USER_ACCOUNT_ID, MOCK_CURRENT_USER_EMAIL, + undefined, ValidOptionsConfig, ); await measureFunction(() => { @@ -191,6 +193,7 @@ describe('OptionsListUtils', () => { loginList, MOCK_CURRENT_USER_ACCOUNT_ID, MOCK_CURRENT_USER_EMAIL, + undefined, { betas: mockedBetas, includeMultipleParticipantReports: true, diff --git a/tests/unit/OptionsListUtilsTest.tsx b/tests/unit/OptionsListUtilsTest.tsx index e9d066817d96..d49e0253616c 100644 --- a/tests/unit/OptionsListUtilsTest.tsx +++ b/tests/unit/OptionsListUtilsTest.tsx @@ -986,6 +986,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // When we call orderOptions() results = orderOptions(results); @@ -1025,6 +1026,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // When we call orderOptions() results = orderOptions(results); @@ -1052,7 +1054,16 @@ describe('OptionsListUtils', () => { it('should return empty options when no reports or personal details are provided', () => { // Given empty arrays of reports and personalDetails // When we call getValidOptions() - const results = getValidOptions({reports: [], personalDetails: []}, allPolicies, {}, nvpDismissedProductTraining, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL); + const results = getValidOptions( + {reports: [], personalDetails: []}, + allPolicies, + {}, + nvpDismissedProductTraining, + loginList, + CURRENT_USER_ACCOUNT_ID, + CURRENT_USER_EMAIL, + undefined, + ); // Then the result should be empty expect(results.personalDetails).toEqual([]); @@ -1074,6 +1085,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // Then the result should include all personalDetails except the currently logged in user @@ -1096,6 +1108,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { excludeLogins: {[CONST.EMAIL.CONCIERGE]: true}, }, @@ -1107,6 +1120,28 @@ describe('OptionsListUtils', () => { expect(results.personalDetails).not.toEqual(expect.arrayContaining([expect.objectContaining({login: 'concierge@expensify.com'})])); }); + it('should pass conciergeReportID through to options when provided', () => { + // Given a set of reports that includes Concierge and a valid conciergeReportID + const conciergeReportID = '11'; + // When we call getValidOptions() with a conciergeReportID + const results = getValidOptions( + {reports: OPTIONS_WITH_CONCIERGE.reports, personalDetails: OPTIONS_WITH_CONCIERGE.personalDetails}, + allPolicies, + {}, + nvpDismissedProductTraining, + loginList, + CURRENT_USER_ACCOUNT_ID, + CURRENT_USER_EMAIL, + conciergeReportID, + ); + + // Then the result should still include Concierge in the results + expect(results.recentReports).toEqual(expect.arrayContaining([expect.objectContaining({login: 'concierge@expensify.com'})])); + // And the concierge report should have a valid reportID + const conciergeOption = results.recentReports.find((option) => option.login === 'concierge@expensify.com'); + expect(conciergeOption?.reportID).toBe(conciergeReportID); + }); + it('should exclude Chronos when excludedLogins is specified', () => { // Given a set of reports and personalDetails that includes Chronos and a config object that excludes Chronos // When we call getValidOptions() @@ -1118,6 +1153,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { excludeLogins: {[CONST.EMAIL.CHRONOS]: true}, }, @@ -1143,6 +1179,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { excludeLogins: {[CONST.EMAIL.RECEIPTS]: true}, }, @@ -1170,6 +1207,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { includeP2P: true, canShowManagerMcTest: true, @@ -1194,6 +1232,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { includeP2P: true, canShowManagerMcTest: false, @@ -1227,6 +1266,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { includeP2P: true, canShowManagerMcTest: true, @@ -1284,6 +1324,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { includeMultipleParticipantReports: true, }, @@ -1338,6 +1379,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { includeMultipleParticipantReports: true, showRBR: true, @@ -1390,6 +1432,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { includeMultipleParticipantReports: true, showRBR: false, @@ -1446,6 +1489,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { includeRecentReports: true, shouldUnreadBeBold: true, @@ -1481,6 +1525,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { personalDetails: customPersonalDetails, }, @@ -1497,7 +1542,7 @@ describe('OptionsListUtils', () => { it('should include all reports by default', () => { // Given a set of reports and personalDetails that includes workspace rooms // When we call getValidOptions() - const results = getValidOptions(OPTIONS_WITH_WORKSPACE_ROOM, allPolicies, {}, nvpDismissedProductTraining, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, { + const results = getValidOptions(OPTIONS_WITH_WORKSPACE_ROOM, allPolicies, {}, nvpDismissedProductTraining, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, undefined, { includeRecentReports: true, includeMultipleParticipantReports: true, includeP2P: true, @@ -1529,7 +1574,7 @@ describe('OptionsListUtils', () => { }; // When we call getValidOptions with shouldSeparateWorkspaceChat and personalDetails config - const results = getValidOptions(OPTIONS_WITH_WORKSPACE_ROOM, allPolicies, {}, nvpDismissedProductTraining, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, { + const results = getValidOptions(OPTIONS_WITH_WORKSPACE_ROOM, allPolicies, {}, nvpDismissedProductTraining, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, undefined, { includeRecentReports: true, includeMultipleParticipantReports: true, includeP2P: true, @@ -1547,7 +1592,7 @@ describe('OptionsListUtils', () => { it('should handle undefined personalDetails config in workspace chat lookups', () => { // Given a set of reports with workspace rooms // When we call getValidOptions with shouldSeparateWorkspaceChat but no personalDetails config - const results = getValidOptions(OPTIONS_WITH_WORKSPACE_ROOM, allPolicies, {}, nvpDismissedProductTraining, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, { + const results = getValidOptions(OPTIONS_WITH_WORKSPACE_ROOM, allPolicies, {}, nvpDismissedProductTraining, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, undefined, { includeRecentReports: true, includeMultipleParticipantReports: true, includeP2P: true, @@ -1564,7 +1609,7 @@ describe('OptionsListUtils', () => { it('should handle empty personalDetails config in workspace chat lookups', () => { // Given a set of reports with workspace rooms // When we call getValidOptions with shouldSeparateWorkspaceChat and empty personalDetails - const results = getValidOptions(OPTIONS_WITH_WORKSPACE_ROOM, allPolicies, {}, nvpDismissedProductTraining, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, { + const results = getValidOptions(OPTIONS_WITH_WORKSPACE_ROOM, allPolicies, {}, nvpDismissedProductTraining, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, undefined, { includeRecentReports: true, includeMultipleParticipantReports: true, includeP2P: true, @@ -1581,7 +1626,7 @@ describe('OptionsListUtils', () => { it('should handle null personalDetails config in workspace chat lookups', () => { // Given a set of reports with workspace rooms // When we call getValidOptions with shouldSeparateWorkspaceChat and null personalDetails - const results = getValidOptions(OPTIONS_WITH_WORKSPACE_ROOM, allPolicies, {}, nvpDismissedProductTraining, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, { + const results = getValidOptions(OPTIONS_WITH_WORKSPACE_ROOM, allPolicies, {}, nvpDismissedProductTraining, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, undefined, { includeRecentReports: true, includeMultipleParticipantReports: true, includeP2P: true, @@ -1608,6 +1653,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); const reportLogins = new Set(results.recentReports.map((reportOption) => reportOption.login)); const personalDetailsOverlapWithReports = results.personalDetails.every((personalDetailOption) => reportLogins.has(personalDetailOption.login)); @@ -1629,6 +1675,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { excludeLogins: {'peterparker@expensify.com': true}, }, @@ -1650,6 +1697,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // Then the result should include all personalDetails except the currently logged in user @@ -1672,6 +1720,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { excludeLogins: {[CONST.EMAIL.CONCIERGE]: true}, }, @@ -1695,6 +1744,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { excludeLogins: {[CONST.EMAIL.CHRONOS]: true}, }, @@ -1721,6 +1771,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { excludeLogins: {[CONST.EMAIL.RECEIPTS]: true}, }, @@ -1745,6 +1796,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { maxRecentReportElements: maxRecentReports, }, @@ -1765,6 +1817,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); const resultsWithLimit = getValidOptions( {reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, @@ -1774,6 +1827,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { maxRecentReportElements: 2, }, @@ -1794,6 +1848,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); const resultsWithLimit = getValidOptions( {reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, @@ -1803,6 +1858,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { maxRecentReportElements: 2, }, @@ -1825,6 +1881,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { maxElements: maxTotalElements, maxRecentReportElements: maxRecentReports, @@ -1859,6 +1916,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { betas: [], includeMultipleParticipantReports: true, @@ -1900,6 +1958,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { betas: [], includeMultipleParticipantReports: true, @@ -2370,6 +2429,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT, }, @@ -2480,6 +2540,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { betas: [], includeMultipleParticipantReports: true, @@ -2522,6 +2583,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { betas: [], includeMultipleParticipantReports: true, @@ -2564,6 +2626,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { betas: [], includeMultipleParticipantReports: true, @@ -2596,6 +2659,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // When we call filterAndOrderOptions with a search value that matches a personal detail with no existing report const filteredOptions = filterAndOrderOptions(options, 'hulk', COUNTRY_CODE, loginList, CURRENT_USER_EMAIL, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS); @@ -2821,6 +2885,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // When we call filterAndOrderOptions with a search value that does not match any personal details or reports const filteredOptions = filterAndOrderOptions(options, 'marc@expensify', COUNTRY_CODE, loginList, CURRENT_USER_EMAIL, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS); @@ -2842,6 +2907,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // When we call filterAndOrderOptions with a search value that does not match any personal details or reports const filteredOptions = filterAndOrderOptions(options, 'marc@expensify.com', COUNTRY_CODE, loginList, CURRENT_USER_EMAIL, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS); @@ -2863,6 +2929,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // When we call filterAndOrderOptions with a search value that does not match any personal details or reports but matches user to invite const filteredOptions = filterAndOrderOptions(options, 'peter.parker@expensify.com', COUNTRY_CODE, loginList, CURRENT_USER_EMAIL, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS); @@ -2883,6 +2950,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // When we call filterAndOrderOptions with a search value without accent mark const filteredOptions = filterAndOrderOptions(options, 'Timothee', COUNTRY_CODE, loginList, CURRENT_USER_EMAIL, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS); @@ -2901,6 +2969,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // When we call filterAndOrderOptions with a search value that does not match any personal details or reports but matches user to invite const filteredOptions = filterAndOrderOptions(options, '5005550006', COUNTRY_CODE, loginList, CURRENT_USER_EMAIL, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS); @@ -2924,6 +2993,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // When we call filterAndOrderOptions with a search value that does not match any personal details or reports but matches user to invite const filteredOptions = filterAndOrderOptions(options, '+15005550006', COUNTRY_CODE, loginList, CURRENT_USER_EMAIL, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS); @@ -2947,6 +3017,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // When we call filterAndOrderOptions with a search value that does not match any personal details or reports but matches user to invite const filteredOptions = filterAndOrderOptions(options, '+1 (800)324-3233', COUNTRY_CODE, loginList, CURRENT_USER_EMAIL, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS); @@ -2970,6 +3041,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // When we call filterAndOrderOptions with a search value that does not match any personal details or reports const filteredOptions = filterAndOrderOptions(options, '998243aaaa', COUNTRY_CODE, loginList, CURRENT_USER_EMAIL, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS); @@ -2991,6 +3063,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { includeUserToInvite: true, }, @@ -3015,6 +3088,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { includeUserToInvite: true, }, @@ -3039,6 +3113,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // When we call filterAndOrderOptions with a search value that does not match any personal details const filteredOptions = filterAndOrderOptions(options, 'magneto', COUNTRY_CODE, loginList, CURRENT_USER_EMAIL, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS); @@ -3057,6 +3132,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // When we call filterAndOrderOptions with a search value that matches an email const filteredOptions = filterAndOrderOptions(options, 'peterparker@expensify.com', COUNTRY_CODE, loginList, CURRENT_USER_EMAIL, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS, { @@ -3081,6 +3157,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // When we call filterAndOrderOptions with a search value that matches both reports and personal details and maxRecentReportsToShow param const filteredOptions = filterAndOrderOptions(options, '.com', COUNTRY_CODE, loginList, CURRENT_USER_EMAIL, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS, { @@ -5214,7 +5291,16 @@ describe('OptionsListUtils', () => { const policies = {[`${ONYXKEYS.COLLECTION.POLICY}${policy.id}`]: policy}; // Test that getValidOptions accepts policies collection as second parameter - const results = getValidOptions({reports: [], personalDetails: []}, policies, undefined, nvpDismissedProductTraining, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL); + const results = getValidOptions( + {reports: [], personalDetails: []}, + policies, + undefined, + nvpDismissedProductTraining, + loginList, + CURRENT_USER_ACCOUNT_ID, + CURRENT_USER_EMAIL, + undefined, + ); expect(results).toBeDefined(); expect(results.recentReports).toBeDefined(); @@ -5223,7 +5309,7 @@ describe('OptionsListUtils', () => { it('should work with undefined policies', () => { const options = {reports: [], personalDetails: []}; - const results = getValidOptions(options, undefined, undefined, nvpDismissedProductTraining, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL); + const results = getValidOptions(options, undefined, undefined, nvpDismissedProductTraining, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, undefined); expect(results).toBeDefined(); expect(results.recentReports).toBeDefined(); @@ -5232,7 +5318,7 @@ describe('OptionsListUtils', () => { it('should work with empty policies collection', () => { const options = {reports: [], personalDetails: []}; - const results = getValidOptions(options, {}, undefined, nvpDismissedProductTraining, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL); + const results = getValidOptions(options, {}, undefined, nvpDismissedProductTraining, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, undefined); expect(results).toBeDefined(); expect(results.recentReports).toBeDefined(); @@ -5264,6 +5350,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { betas: [], includeRecentReports: true, @@ -6644,6 +6731,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // Then the function should complete without errors and return valid results @@ -6662,6 +6750,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // When we call filterAndOrderOptions with the reports parameter @@ -6716,6 +6805,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // Then the function should still work correctly @@ -6734,6 +6824,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, ); // Then the function should still work correctly @@ -7367,6 +7458,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { includeRecentReports: true, includeMultipleParticipantReports: true, @@ -7430,6 +7522,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { includeRecentReports: true, action: CONST.IOU.ACTION.CREATE, @@ -7489,6 +7582,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { includeRecentReports: true, action: CONST.IOU.ACTION.CREATE, @@ -7574,6 +7668,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { includeRecentReports: true, includeMultipleParticipantReports: true, @@ -7653,6 +7748,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { includeRecentReports: true, sortedActions, @@ -7720,6 +7816,7 @@ describe('OptionsListUtils', () => { loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, + undefined, { includeRecentReports: true, action: CONST.IOU.ACTION.CREATE, diff --git a/tests/unit/useSearchSelectorTest.tsx b/tests/unit/useSearchSelectorTest.tsx index e58167a8645d..d81776b33322 100644 --- a/tests/unit/useSearchSelectorTest.tsx +++ b/tests/unit/useSearchSelectorTest.tsx @@ -106,7 +106,7 @@ describe('useSearchSelector sortedActions integration', () => { expect(mockGetValidOptions).toHaveBeenCalled(); const lastCall = mockGetValidOptions.mock.calls.at(-1); - const config = lastCall?.[7]; + const config = lastCall?.[8]; expect(config?.sortedActions).toBeUndefined(); }); @@ -128,7 +128,7 @@ describe('useSearchSelector sortedActions integration', () => { expect(mockGetValidOptions).toHaveBeenCalled(); const lastCall = mockGetValidOptions.mock.calls.at(-1); - const config = lastCall?.[7]; + const config = lastCall?.[8]; expect(config?.sortedActions).toEqual(mockData.sortedActions); }); @@ -150,7 +150,7 @@ describe('useSearchSelector sortedActions integration', () => { expect(mockGetValidOptions).toHaveBeenCalled(); const lastCall = mockGetValidOptions.mock.calls.at(-1); - const config = lastCall?.[7]; + const config = lastCall?.[8]; expect(config?.sortedActions).toEqual(mockData.sortedActions); }); @@ -172,7 +172,7 @@ describe('useSearchSelector sortedActions integration', () => { expect(mockGetValidOptions).toHaveBeenCalled(); const lastCall = mockGetValidOptions.mock.calls.at(-1); - const config = lastCall?.[7]; + const config = lastCall?.[8]; expect(config?.sortedActions).toEqual(mockData.sortedActions); }); @@ -194,7 +194,7 @@ describe('useSearchSelector sortedActions integration', () => { expect(mockGetValidOptions).toHaveBeenCalled(); const lastCall = mockGetValidOptions.mock.calls.at(-1); - const config = lastCall?.[7]; + const config = lastCall?.[8]; expect(config?.sortedActions).toEqual(mockData.sortedActions); }); @@ -214,7 +214,7 @@ describe('useSearchSelector sortedActions integration', () => { ); await waitForBatchedUpdatesWithAct(); - const firstCallConfig = mockGetValidOptions.mock.calls.at(-1)?.[7]; + const firstCallConfig = mockGetValidOptions.mock.calls.at(-1)?.[8]; expect(firstCallConfig?.sortedActions).toEqual(initialData.sortedActions); const updatedData = buildMockSortedActions(['1', '2', '3']); @@ -223,7 +223,7 @@ describe('useSearchSelector sortedActions integration', () => { }); await waitForBatchedUpdatesWithAct(); - const latestCallConfig = mockGetValidOptions.mock.calls.at(-1)?.[7]; + const latestCallConfig = mockGetValidOptions.mock.calls.at(-1)?.[8]; expect(latestCallConfig?.sortedActions).toEqual(updatedData.sortedActions); });