diff --git a/src/components/LHNOptionsList/LHNOptionsList.tsx b/src/components/LHNOptionsList/LHNOptionsList.tsx index 67d7a0a26b6bf..1388492da966a 100644 --- a/src/components/LHNOptionsList/LHNOptionsList.tsx +++ b/src/components/LHNOptionsList/LHNOptionsList.tsx @@ -10,7 +10,6 @@ import type {OnyxEntry} from 'react-native-onyx'; import type {BlockingViewProps} from '@components/BlockingViews/BlockingView'; import BlockingView from '@components/BlockingViews/BlockingView'; import Icon from '@components/Icon'; -import * as Expensicons from '@components/Icon/Expensicons'; import {ScrollOffsetContext} from '@components/ScrollOffsetContextProvider'; import TextBlock from '@components/TextBlock'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; @@ -57,7 +56,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio const flashListRef = useRef>(null); const route = useRoute(); const isScreenFocused = useIsFocused(); - const expensifyIcons = useMemoizedLazyExpensifyIcons(['MagnifyingGlass']); + const expensifyIcons = useMemoizedLazyExpensifyIcons(['MagnifyingGlass', 'Plus']); const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: false}); const [reportAttributes] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {selector: reportsSelector, canBeMissing: true}); @@ -73,6 +72,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); const [onboarding] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {canBeMissing: true}); const [isFullscreenVisible] = useOnyx(ONYXKEYS.FULLSCREEN_VISIBILITY, {canBeMissing: true}); + const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {canBeMissing: false}); const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); const {policyForMovingExpensesID} = usePolicyForMovingExpenses(); @@ -140,7 +140,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio text={translate('common.emptyLHN.subtitleText2')} /> deepEqual(prevReportErrors, reportAttributes?.reportErrors), [prevReportErrors, reportAttributes?.reportErrors]); @@ -78,6 +80,7 @@ function OptionRowLHNData({ lastActionReport, movedFromReport, movedToReport, + policyTags, currentUserAccountID, reportAttributesDerived, }); @@ -115,6 +118,7 @@ function OptionRowLHNData({ isReportArchived, movedFromReport, movedToReport, + policyTags, currentUserAccountID, reportAttributesDerived, ]); diff --git a/src/components/OptionListContextProvider.tsx b/src/components/OptionListContextProvider.tsx index 38de7a5f48099..5d53ed48b3fd9 100644 --- a/src/components/OptionListContextProvider.tsx +++ b/src/components/OptionListContextProvider.tsx @@ -7,6 +7,7 @@ import usePrivateIsArchivedMap from '@hooks/usePrivateIsArchivedMap'; import {createOptionFromReport, createOptionList, processReport, shallowOptionsListCompare} from '@libs/OptionsListUtils'; import type {OptionList, SearchOption} from '@libs/OptionsListUtils'; import {isSelfDM} from '@libs/ReportUtils'; +import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {PersonalDetails, Report} from '@src/types/onyx'; import {usePersonalDetails} from './OnyxListItemProvider'; @@ -59,15 +60,16 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) { const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const currentUserAccountID = currentUserPersonalDetails.accountID; const hasInitialData = useMemo(() => Object.keys(personalDetails ?? {}).length > 0, [personalDetails]); + const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {canBeMissing: false}); const privateIsArchivedMap = usePrivateIsArchivedMap(); const loadOptions = useCallback(() => { - const optionLists = createOptionList(personalDetails, currentUserAccountID, privateIsArchivedMap, reports, reportAttributes?.reports); + const optionLists = createOptionList(personalDetails, policyTags, currentUserAccountID, privateIsArchivedMap, reports, reportAttributes?.reports); setOptions({ reports: optionLists.reports, personalDetails: optionLists.personalDetails, }); - }, [personalDetails, currentUserAccountID, privateIsArchivedMap, reports, reportAttributes?.reports]); + }, [personalDetails, currentUserAccountID, privateIsArchivedMap, reports, reportAttributes?.reports, policyTags]); /** * This effect is responsible for generating the options list when their data is not yet initialized @@ -123,7 +125,8 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) { for (const reportKey of changedReportKeys) { const report = changedReportsEntries[reportKey]; const reportID = reportKey.replace(ONYXKEYS.COLLECTION.REPORT, ''); - const {reportOption} = processReport(report, personalDetails, currentUserAccountID, reportAttributes?.reports); + const reportPolicyTags = report?.policyID ? policyTags?.[report?.policyID] : CONST.POLICY.DEFAULT_TAG_LIST; + const {reportOption} = processReport(report, personalDetails, reportPolicyTags, currentUserAccountID, reportAttributes?.reports); if (reportOption) { updatedReportsMap.set(reportID, reportOption); @@ -137,7 +140,7 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) { reports: Array.from(updatedReportsMap.values()), }; }); - }, [changedReportsEntries, personalDetails, currentUserAccountID, reportAttributes?.reports]); + }, [changedReportsEntries, personalDetails, currentUserAccountID, reportAttributes?.reports, policyTags]); useEffect(() => { if (!changedReportActions || !areOptionsInitialized.current) { @@ -157,7 +160,9 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) { } const reportID = key.replace(ONYXKEYS.COLLECTION.REPORT_ACTIONS, ''); - const {reportOption} = processReport(updatedReportsMap.get(reportID)?.item, personalDetails, currentUserAccountID, reportAttributes?.reports); + const report = updatedReportsMap.get(reportID)?.item; + const reportPolicyTags = report?.policyID ? policyTags?.[report?.policyID] : CONST.POLICY.DEFAULT_TAG_LIST; + const {reportOption} = processReport(updatedReportsMap.get(reportID)?.item, personalDetails, reportPolicyTags, currentUserAccountID, reportAttributes?.reports); if (reportOption) { updatedReportsMap.set(reportID, reportOption); @@ -169,7 +174,7 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) { reports: Array.from(updatedReportsMap.values()), }; }); - }, [changedReportActions, personalDetails, currentUserAccountID, reportAttributes?.reports]); + }, [changedReportActions, personalDetails, currentUserAccountID, reportAttributes?.reports, policyTags]); /** * This effect is used to update the options list when personal details change. @@ -189,6 +194,7 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) { if (!prevPersonalDetails) { const {personalDetails: newPersonalDetailsOptions, reports: newReports} = createOptionList( personalDetails, + policyTags, currentUserAccountID, privateIsArchivedMap, reports, @@ -226,7 +232,10 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) { continue; } - const newReportOption = createOptionFromReport(report, personalDetails, currentUserAccountID, reportAttributes?.reports, {showPersonalDetails: true}); + const reportPolicyTags = report.policyID ? policyTags?.[report.policyID] : CONST.POLICY.DEFAULT_TAG_LIST; + const newReportOption = createOptionFromReport(report, personalDetails, reportPolicyTags, currentUserAccountID, reportAttributes?.reports, { + showPersonalDetails: true, + }); const replaceIndex = options.reports.findIndex((option) => option.reportID === report.reportID); newReportOptions.push({ newReportOption, @@ -236,7 +245,7 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) { } // since personal details are not a collection, we need to recreate the whole list from scratch - const newPersonalDetailsOptions = createOptionList(personalDetails, currentUserAccountID, privateIsArchivedMap, reports, reportAttributes?.reports).personalDetails; + const newPersonalDetailsOptions = createOptionList(personalDetails, policyTags, currentUserAccountID, privateIsArchivedMap, reports, reportAttributes?.reports).personalDetails; setOptions((prevOptions) => { const newOptions = {...prevOptions}; diff --git a/src/components/Search/FilterDropdowns/UserSelectPopup.tsx b/src/components/Search/FilterDropdowns/UserSelectPopup.tsx index 1c72a1abfb9ac..9279bfea7b005 100644 --- a/src/components/Search/FilterDropdowns/UserSelectPopup.tsx +++ b/src/components/Search/FilterDropdowns/UserSelectPopup.tsx @@ -69,6 +69,7 @@ function UserSelectPopup({value, closeOverlay, onChange, isSearchable}: UserSele const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false, canBeMissing: true}); const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, {canBeMissing: true}); const [nvpDismissedProductTraining] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {canBeMissing: true}); + const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {canBeMissing: true}); const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true}); const initialSelectedOptions = useMemo(() => { return value.reduce((acc, id) => { @@ -106,6 +107,7 @@ function UserSelectPopup({value, closeOverlay, onChange, isSearchable}: UserSele allPolicies, draftComments, nvpDismissedProductTraining, + policyTags, loginList, currentUserAccountID, currentUserEmail, @@ -116,7 +118,19 @@ function UserSelectPopup({value, closeOverlay, onChange, isSearchable}: UserSele }, countryCode, ); - }, [options.reports, options.personalDetails, allPolicies, draftComments, nvpDismissedProductTraining, loginList, countryCode, personalDetails, currentUserAccountID, currentUserEmail]); + }, [ + options.reports, + options.personalDetails, + allPolicies, + draftComments, + nvpDismissedProductTraining, + policyTags, + loginList, + currentUserAccountID, + currentUserEmail, + personalDetails, + countryCode, + ]); const filteredOptions = useMemo(() => { return filterAndOrderOptions(optionsList, cleanSearchTerm, countryCode, loginList, currentUserEmail, currentUserAccountID, personalDetails, { diff --git a/src/components/Search/SearchAutocompleteList.tsx b/src/components/Search/SearchAutocompleteList.tsx index 17ccfe98c14d1..39cf204058659 100644 --- a/src/components/Search/SearchAutocompleteList.tsx +++ b/src/components/Search/SearchAutocompleteList.tsx @@ -195,6 +195,7 @@ function SearchAutocompleteList({ const [nvpDismissedProductTraining] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {canBeMissing: true}); const [recentSearches] = useOnyx(ONYXKEYS.RECENT_SEARCHES, {canBeMissing: true}); const [countryCode] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false}); + const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {canBeMissing: true}); const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST, {canBeMissing: true}); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const currentUserEmail = currentUserPersonalDetails.email ?? ''; @@ -220,6 +221,7 @@ function SearchAutocompleteList({ includeCurrentUser: true, countryCode, shouldShowGBR: false, + policyTags, shouldUnreadBeBold: true, loginList, currentUserAccountID, @@ -237,6 +239,7 @@ function SearchAutocompleteList({ loginList, currentUserAccountID, currentUserEmail, + policyTags, personalDetails, ]); @@ -454,6 +457,7 @@ function SearchAutocompleteList({ countryCode, loginList, shouldShowGBR: true, + policyTags, currentUserAccountID, currentUserEmail, personalDetails, @@ -488,6 +492,7 @@ function SearchAutocompleteList({ countryCode, loginList, shouldShowGBR: true, + policyTags, currentUserAccountID, currentUserEmail, personalDetails, @@ -660,11 +665,13 @@ function SearchAutocompleteList({ currencyAutocompleteList, recentCurrencyAutocompleteList, taxAutocompleteList, + translate, options, draftComments, nvpDismissedProductTraining, betas, countryCode, + policyTags, loginList, currentUserAccountID, currentUserEmail, @@ -673,7 +680,6 @@ function SearchAutocompleteList({ statusAutocompleteList, feedAutoCompleteList, cardAutocompleteList, - translate, workspaceList, hasAutocompleteList, isAutocompleteList, diff --git a/src/components/Search/SearchFiltersChatsSelector.tsx b/src/components/Search/SearchFiltersChatsSelector.tsx index 42ee21c6ed8b3..848fd648fa0df 100644 --- a/src/components/Search/SearchFiltersChatsSelector.tsx +++ b/src/components/Search/SearchFiltersChatsSelector.tsx @@ -63,13 +63,29 @@ function SearchFiltersChatsSelector({initialReportIDs, onFiltersUpdate, isScreen const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, {canBeMissing: true}); const archivedReportsIdSet = useArchivedReportsIdSet(); const [nvpDismissedProductTraining] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {canBeMissing: true}); + const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {canBeMissing: false}); const selectedOptions: OptionData[] = selectedReportIDs.map((id) => { + const selectedReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${id}`]; const report = getSelectedOptionData( - createOptionFromReport({...reports?.[`${ONYXKEYS.COLLECTION.REPORT}${id}`], reportID: id}, personalDetails, currentUserAccountID, reportAttributesDerived), + createOptionFromReport( + {...reports?.[`${ONYXKEYS.COLLECTION.REPORT}${id}`], reportID: id}, + personalDetails, + policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${selectedReport?.policyID}`], + currentUserAccountID, + reportAttributesDerived, + ), ); const isReportArchived = archivedReportsIdSet.has(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.reportID}`); - const alternateText = getAlternateText(report, {}, isReportArchived, currentUserAccountID, {}, reportAttributesDerived); + const alternateText = getAlternateText( + report, + {}, + policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report.policyID}`], + isReportArchived, + currentUserAccountID, + {}, + reportAttributesDerived, + ); return {...report, alternateText}; }); @@ -86,6 +102,7 @@ function SearchFiltersChatsSelector({initialReportIDs, onFiltersUpdate, isScreen loginList, currentUserAccountID, currentUserEmail, + policyTags, personalDetails, }); @@ -102,6 +119,7 @@ function SearchFiltersChatsSelector({initialReportIDs, onFiltersUpdate, isScreen selectedOptions, chatOptions.recentReports, chatOptions.personalDetails, + policyTags, currentUserAccountID, personalDetails, false, diff --git a/src/components/Search/SearchFiltersParticipantsSelector.tsx b/src/components/Search/SearchFiltersParticipantsSelector.tsx index f26ad6b62b720..74a7bcdbdfa00 100644 --- a/src/components/Search/SearchFiltersParticipantsSelector.tsx +++ b/src/components/Search/SearchFiltersParticipantsSelector.tsx @@ -94,6 +94,7 @@ function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate, const cleanSearchTerm = useMemo(() => searchTerm.trim().toLowerCase(), [searchTerm]); const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, {canBeMissing: true}); const [nvpDismissedProductTraining] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {canBeMissing: true}); + const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {canBeMissing: false}); const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true}); const [recentAttendees] = useOnyx(ONYXKEYS.NVP_RECENT_ATTENDEES, {canBeMissing: true}); @@ -116,6 +117,7 @@ function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate, allPolicies, draftComments, nvpDismissedProductTraining, + policyTags, loginList, currentUserAccountID, currentUserEmail, @@ -137,6 +139,7 @@ function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate, allPolicies, draftComments, nvpDismissedProductTraining, + policyTags, loginList, countryCode, recentAttendeeLists, @@ -203,6 +206,7 @@ function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate, selectedOptions, chatOptions.recentReports, chatOptions.personalDetails, + policyTags, currentUserAccountID, personalDetails, true, @@ -263,7 +267,7 @@ function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate, sections: newSections, headerMessage: message, }; - }, [areOptionsInitialized, cleanSearchTerm, selectedOptions, chatOptions, personalDetails, reportAttributesDerived, translate, formatPhoneNumber, currentUserAccountID]); + }, [areOptionsInitialized, cleanSearchTerm, selectedOptions, chatOptions, personalDetails, reportAttributesDerived, translate, formatPhoneNumber, currentUserAccountID, policyTags]); const resetChanges = useCallback(() => { setSelectedOptions([]); diff --git a/src/components/Search/SearchRouter/SearchRouter.tsx b/src/components/Search/SearchRouter/SearchRouter.tsx index 8bd3fbe6c7c7c..689d4a9f1c2b2 100644 --- a/src/components/Search/SearchRouter/SearchRouter.tsx +++ b/src/components/Search/SearchRouter/SearchRouter.tsx @@ -76,6 +76,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla const [allFeeds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER, {canBeMissing: true}); const {shouldUseNarrowLayout} = useResponsiveLayout(); const listRef = useRef(null); + const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {canBeMissing: true}); const expensifyIcons = useMemoizedLazyExpensifyIcons(['MagnifyingGlass']); // The actual input text that the user sees @@ -111,8 +112,8 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla if (!report) { return undefined; } - - const option = createOptionFromReport(report, personalDetails, currentUserAccountID, undefined, {showPersonalDetails: true}); + const reportPolicyTags = report.policyID ? policyTags?.[report.policyID] : CONST.POLICY.DEFAULT_TAG_LIST; + const option = createOptionFromReport(report, personalDetails, reportPolicyTags, currentUserAccountID, undefined, {showPersonalDetails: true}); reportForContextualSearch = option; } @@ -172,6 +173,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla expensifyIcons.MagnifyingGlass, styles.activeComponentBG, reports, + policyTags, personalDetails, currentUserAccountID, ], diff --git a/src/hooks/useFilteredOptions.ts b/src/hooks/useFilteredOptions.ts index d27088293fa1a..991001bf69481 100644 --- a/src/hooks/useFilteredOptions.ts +++ b/src/hooks/useFilteredOptions.ts @@ -77,13 +77,14 @@ function useFilteredOptions(config: UseFilteredOptionsConfig = {}): UseFilteredO canBeMissing: true, selector: reportsSelector, }); + const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {canBeMissing: false}); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const totalReports = allReports ? Object.keys(allReports).length : 0; const options: OptionList | null = enabled && allReports && allPersonalDetails - ? createFilteredOptionList(allPersonalDetails, allReports, currentUserPersonalDetails.accountID, reportAttributesDerived, { + ? createFilteredOptionList(allPersonalDetails, allReports, policyTags, currentUserPersonalDetails.accountID, reportAttributesDerived, { maxRecentReports: reportsLimit, includeP2P, searchTerm, diff --git a/src/hooks/useSearchSelector.base.ts b/src/hooks/useSearchSelector.base.ts index 80d78e9af64a8..389e7df4aab31 100644 --- a/src/hooks/useSearchSelector.base.ts +++ b/src/hooks/useSearchSelector.base.ts @@ -172,6 +172,7 @@ function useSearchSelectorBase({ const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true}); const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, {canBeMissing: true}); const [nvpDismissedProductTraining] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {canBeMissing: true}); + const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {canBeMissing: false}); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const currentUserAccountID = currentUserPersonalDetails.accountID; const currentUserEmail = currentUserPersonalDetails.email ?? ''; @@ -210,6 +211,7 @@ function useSearchSelectorBase({ loginList, currentUserAccountID, currentUserEmail, + policyTags, personalDetails, }); case CONST.SEARCH_SELECTOR.SEARCH_CONTEXT_MEMBER_INVITE: @@ -218,6 +220,7 @@ function useSearchSelectorBase({ allPolicies, draftComments, nvpDismissedProductTraining, + policyTags, loginList, currentUserAccountID, currentUserEmail, @@ -244,6 +247,7 @@ function useSearchSelectorBase({ allPolicies, draftComments, nvpDismissedProductTraining, + policyTags, loginList, currentUserAccountID, currentUserEmail, @@ -268,6 +272,7 @@ function useSearchSelectorBase({ allPolicies, draftComments, nvpDismissedProductTraining, + policyTags, loginList, currentUserAccountID, currentUserEmail, @@ -295,6 +300,7 @@ function useSearchSelectorBase({ allPolicies, draftComments, nvpDismissedProductTraining, + policyTags, loginList, currentUserAccountID, currentUserEmail, @@ -326,6 +332,7 @@ function useSearchSelectorBase({ allPolicies, draftComments, nvpDismissedProductTraining, + policyTags, loginList, currentUserAccountID, currentUserEmail, @@ -365,6 +372,7 @@ function useSearchSelectorBase({ includeUserToInvite, countryCode, loginList, + policyTags, excludeLogins, excludeFromSuggestionsOnly, includeRecentReports, @@ -377,6 +385,7 @@ function useSearchSelectorBase({ personalDetails, reportAttributesDerived?.reports, trimmedSearchInput, + allPolicies, ]); const isOptionSelected = useMemo(() => { diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index fb5e52e3be0e0..da1d0c3628914 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -639,7 +639,7 @@ function getForReportActionTemp({ const splittedTag = getTagArrayFromName(transactionTag); const splittedOldTag = getTagArrayFromName(oldTransactionTag); const localizedTagListName = translate('common.tag'); - const sortedTagKeys = getSortedTagKeys(policyTags); + const sortedTagKeys = getSortedTagKeys(policyTags ?? CONST.POLICY.DEFAULT_TAG_LIST); for (const [index, policyTagKey] of sortedTagKeys.entries()) { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing @@ -690,30 +690,17 @@ function getForReportActionTemp({ const hasModifiedBillable = isReportActionOriginalMessageAnObject && 'oldBillable' in reportActionOriginalMessage && 'billable' in reportActionOriginalMessage; if (hasModifiedBillable) { - buildMessageFragmentForValue( - translate, - reportActionOriginalMessage?.billable ?? '', - reportActionOriginalMessage?.oldBillable ?? '', - translate('iou.expense'), - true, - setFragments, - removalFragments, - changeFragments, - ); + const oldBillable = reportActionOriginalMessage?.oldBillable === 'billable' ? translate('common.billable').toLowerCase() : translate('common.nonBillable').toLowerCase(); + const newBillable = reportActionOriginalMessage?.billable === 'billable' ? translate('common.billable').toLowerCase() : translate('common.nonBillable').toLowerCase(); + buildMessageFragmentForValue(translate, newBillable, oldBillable, translate('iou.expense'), true, setFragments, removalFragments, changeFragments); } const hasModifiedReimbursable = isReportActionOriginalMessageAnObject && 'oldReimbursable' in reportActionOriginalMessage && 'reimbursable' in reportActionOriginalMessage; if (hasModifiedReimbursable) { - buildMessageFragmentForValue( - translate, - reportActionOriginalMessage?.reimbursable ?? '', - reportActionOriginalMessage?.oldReimbursable ?? '', - translate('iou.expense'), - true, - setFragments, - removalFragments, - changeFragments, - ); + const oldReimbursable = + reportActionOriginalMessage?.oldReimbursable === 'reimbursable' ? translate('iou.reimbursable').toLowerCase() : translate('iou.nonReimbursable').toLowerCase(); + const newReimbursable = reportActionOriginalMessage?.reimbursable === 'reimbursable' ? translate('iou.reimbursable').toLowerCase() : translate('iou.nonReimbursable').toLowerCase(); + buildMessageFragmentForValue(translate, newReimbursable, oldReimbursable, translate('iou.expense'), true, setFragments, removalFragments, changeFragments); } const hasModifiedAttendees = isReportActionOriginalMessageAnObject && 'oldAttendees' in reportActionOriginalMessage && 'newAttendees' in reportActionOriginalMessage; @@ -738,6 +725,13 @@ function getForReportActionTemp({ getMessageLine(translate, `\n${translate('iou.removed')}`, removalFragments); if (message === '') { + // If we don't have enough structured information to build a detailed message but we + // know the change was AI-generated, fall back to an AI-attributed generic summary so + // users can still understand that Concierge updated the expense automatically. + if (reportActionOriginalMessage?.aiGenerated) { + return `${translate('iou.changedTheExpense')} ${translate('iou.basedOnAI')}`; + } + return translate('iou.changedTheExpense'); } return `${message.substring(1, message.length)}`; diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 3ba2fee6c162b..3413cbd4d9dab 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -17,7 +17,7 @@ import {translateLocal} from '@libs/Localize'; import {appendCountryCode, getPhoneNumberWithoutSpecialChars} from '@libs/LoginUtils'; import {MaxHeap} from '@libs/MaxHeap'; import {MinHeap} from '@libs/MinHeap'; -import {getForReportAction} from '@libs/ModifiedExpenseMessage'; +import {getForReportActionTemp} from '@libs/ModifiedExpenseMessage'; import Navigation from '@libs/Navigation/Navigation'; import Parser from '@libs/Parser'; import Performance from '@libs/Performance'; @@ -460,6 +460,7 @@ function shouldShowLastActorDisplayName( function getAlternateText( option: OptionData, {showChatPreviewLine = false, forcePolicyNamePreview = false}: PreviewConfig, + policyTags: OnyxEntry, isReportArchived: boolean | undefined, currentUserAccountID: number, lastActorDetails: Partial | null = {}, @@ -473,7 +474,7 @@ function getAlternateText( const formattedLastMessageText = formatReportLastMessageText(Parser.htmlToText(option.lastMessageText ?? '')) || // eslint-disable-next-line @typescript-eslint/no-deprecated - getLastMessageTextForReport({translate: translateLocal, report, lastActorDetails, isReportArchived, reportAttributesDerived}); + getLastMessageTextForReport({translate: translateLocal, report, lastActorDetails, isReportArchived, policyTags, reportAttributesDerived}); const reportPrefix = getReportSubtitlePrefix(report); const formattedLastMessageTextWithPrefix = reportPrefix + formattedLastMessageText; @@ -606,7 +607,7 @@ function getLastMessageTextForReport({ movedToReport, policy, isReportArchived = false, - policyForMovingExpensesID, + policyTags, reportMetadata, reportAttributesDerived, }: { @@ -617,7 +618,7 @@ function getLastMessageTextForReport({ movedToReport?: OnyxEntry; policy?: OnyxEntry; isReportArchived?: boolean; - policyForMovingExpensesID?: string; + policyTags: OnyxEntry; reportMetadata?: OnyxEntry; reportAttributesDerived?: ReportAttributesDerivedValue['reports']; }): string { @@ -693,12 +694,13 @@ function getLastMessageTextForReport({ } else if (isReportMessageAttachment({text: report?.lastMessageText ?? '', html: report?.lastMessageHtml, type: ''})) { lastMessageTextFromReport = `[${translate('common.attachment')}]`; } else if (isModifiedExpenseAction(lastReportAction)) { - const properSchemaForModifiedExpenseMessage = getForReportAction({ + const properSchemaForModifiedExpenseMessage = getForReportActionTemp({ + translate, reportAction: lastReportAction, - policyID: report?.policyID, movedFromReport, movedToReport, - policyForMovingExpensesID, + policyTags, + policy, }); lastMessageTextFromReport = formatReportLastMessageText(properSchemaForModifiedExpenseMessage, true); } else if (isMovedTransactionAction(lastReportAction)) { @@ -867,6 +869,7 @@ function createOption( accountIDs: number[], personalDetails: OnyxInputOrEntry, report: OnyxInputOrEntry, + policyTags: OnyxEntry, currentUserAccountID: number, config?: PreviewConfig, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], @@ -952,12 +955,21 @@ function createOption( report, lastActorDetails, isReportArchived: !!result.private_isArchived, + policyTags, reportAttributesDerived, }); result.alternateText = showPersonalDetails && personalDetail?.login ? personalDetail.login - : getAlternateText(result, {showChatPreviewLine, forcePolicyNamePreview}, !!result.private_isArchived, currentUserAccountID, lastActorDetails, reportAttributesDerived); + : getAlternateText( + result, + {showChatPreviewLine, forcePolicyNamePreview}, + policyTags, + !!result.private_isArchived, + currentUserAccountID, + lastActorDetails, + reportAttributesDerived, + ); const computedReportName = getReportName(report, reportAttributesDerived); @@ -1004,6 +1016,7 @@ function createOption( */ function getReportOption( participant: Participant, + policyTags: OnyxEntry, privateIsArchived: string | undefined, policy: OnyxEntry, currentUserAccountID: number, @@ -1018,6 +1031,7 @@ function getReportOption( visibleParticipantAccountIDs, personalDetails ?? {}, !isEmptyObject(report) ? report : undefined, + policyTags, currentUserAccountID, { showChatPreviewLine: false, @@ -1064,6 +1078,7 @@ function getReportOption( function getReportDisplayOption( report: OnyxEntry, unknownUserDetails: OnyxEntry, + policyTags: OnyxEntry, currentUserAccountID: number, personalDetails: OnyxEntry, privateIsArchived: string | undefined, @@ -1075,6 +1090,7 @@ function getReportDisplayOption( visibleParticipantAccountIDs, personalDetails ?? {}, !isEmptyObject(report) ? report : undefined, + policyTags, currentUserAccountID, { showChatPreviewLine: false, @@ -1112,6 +1128,7 @@ function getReportDisplayOption( */ function getPolicyExpenseReportOption( participant: Participant | SearchOptionData, + policyTags: OnyxCollection, currentUserAccountID: number, personalDetails: OnyxEntry, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], @@ -1121,11 +1138,12 @@ function getPolicyExpenseReportOption( const visibleParticipantAccountIDs = Object.entries(expenseReport?.participants ?? {}) .filter(([, reportParticipant]) => reportParticipant && !isHiddenForCurrentUser(reportParticipant.notificationPreference)) .map(([accountID]) => Number(accountID)); - + const reportPolicyTags = expenseReport?.policyID ? policyTags?.[expenseReport.policyID] : CONST.POLICY.DEFAULT_TAG_LIST; const option = createOption( visibleParticipantAccountIDs, personalDetails ?? {}, !isEmptyObject(expenseReport) ? expenseReport : null, + reportPolicyTags, currentUserAccountID, { showChatPreviewLine: false, @@ -1240,6 +1258,7 @@ function isReportSelected(reportOption: SearchOptionData, selectedOptions: Array function processReport( report: OnyxEntry | null, personalDetails: OnyxEntry, + policyTags: OnyxEntry, currentUserAccountID: number, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], ): { @@ -1265,13 +1284,14 @@ function processReport( reportMapEntry, reportOption: { item: report, - ...createOption(accountIDs, personalDetails, report, currentUserAccountID, undefined, reportAttributesDerived), + ...createOption(accountIDs, personalDetails, report, policyTags, currentUserAccountID, undefined, reportAttributesDerived), }, }; } function createOptionList( personalDetails: OnyxEntry, + policyTags: OnyxCollection, currentUserAccountID: number, privateIsArchivedMap: PrivateIsArchivedMap, reports?: OnyxCollection, @@ -1284,7 +1304,8 @@ function createOptionList( if (reports) { for (const report of Object.values(reports)) { - const {reportMapEntry, reportOption} = processReport(report, personalDetails, currentUserAccountID, reportAttributesDerived); + const reportPolicyTags = report?.policyID ? policyTags?.[report?.policyID] : CONST.POLICY.DEFAULT_TAG_LIST; + const {reportMapEntry, reportOption} = processReport(report, personalDetails, reportPolicyTags, currentUserAccountID, reportAttributesDerived); if (reportMapEntry) { const [accountID, reportValue] = reportMapEntry; @@ -1299,6 +1320,7 @@ function createOptionList( const allPersonalDetailsOptions = Object.values(personalDetails ?? {}).map((personalDetail) => { const report = reportMapForAccountIDs[personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID]; + const policyTagList = report?.policyID ? policyTags?.[report?.policyID] : CONST.POLICY.DEFAULT_TAG_LIST; const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`]; return { @@ -1307,6 +1329,7 @@ function createOptionList( [personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID], personalDetails, report, + policyTagList, currentUserAccountID, { showPersonalDetails: true, @@ -1345,6 +1368,7 @@ function createOptionList( function createFilteredOptionList( personalDetails: OnyxEntry, reports: OnyxCollection, + policyTags: OnyxCollection, currentUserAccountID: number, reportAttributesDerived: ReportAttributesDerivedValue['reports'] | undefined, options: { @@ -1402,7 +1426,8 @@ function createFilteredOptionList( // Step 5: Process the limited set of reports (performance optimization) const reportOptions: Array> = []; for (const report of limitedReports) { - const {reportMapEntry, reportOption} = processReport(report, personalDetails, currentUserAccountID, reportAttributesDerived); + const reportPolicyTags = report?.policyID ? policyTags?.[report?.policyID] : CONST.POLICY.DEFAULT_TAG_LIST; + const {reportMapEntry, reportOption} = processReport(report, personalDetails, reportPolicyTags, currentUserAccountID, reportAttributesDerived); if (reportMapEntry) { const [accountID, reportValue] = reportMapEntry; @@ -1429,10 +1454,20 @@ function createFilteredOptionList( const personalDetailsOptions = includeP2P ? Object.values(personalDetails ?? {}).map((personalDetail) => { const accountID = personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID; + const report = reportMapForAccountIDs[accountID]; + const reportPolicyTags = report?.policyID ? policyTags?.[report?.policyID] : undefined; return { item: personalDetail, - ...createOption([accountID], personalDetails, reportMapForAccountIDs[accountID], currentUserAccountID, {showPersonalDetails: true}, reportAttributesDerived), + ...createOption( + [accountID], + personalDetails, + reportMapForAccountIDs[accountID], + reportPolicyTags, + currentUserAccountID, + {showPersonalDetails: true}, + reportAttributesDerived, + ), }; }) : []; @@ -1446,6 +1481,7 @@ function createFilteredOptionList( function createOptionFromReport( report: Report, personalDetails: OnyxEntry, + policyTags: OnyxEntry, currentUserAccountID: number, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], config?: PreviewConfig, @@ -1454,7 +1490,7 @@ function createOptionFromReport( return { item: report, - ...createOption(accountIDs, personalDetails, report, currentUserAccountID, config, reportAttributesDerived), + ...createOption(accountIDs, personalDetails, report, policyTags, currentUserAccountID, config, reportAttributesDerived), }; } @@ -1774,7 +1810,7 @@ function getUserToInviteOption({ login: searchValue, }, }; - const userToInvite = createOption([optimisticAccountID], personalDetailsExtended, null, currentUserAccountID, { + const userToInvite = createOption([optimisticAccountID], personalDetailsExtended, null, undefined, currentUserAccountID, { showChatPreviewLine, }); userToInvite.isOptimisticAccount = true; @@ -2055,6 +2091,7 @@ function prepareReportOptionsForDisplay( policiesCollection: OnyxCollection, currentUserAccountID: number, config: GetValidReportsConfig, + policyTags: OnyxCollection, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], ): Array> { const { @@ -2081,12 +2118,21 @@ function prepareReportOptionsForDisplay( continue; } const report = option.item; + const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report.policyID}`]; /** * By default, generated options does not have the chat preview line enabled. * If showChatPreviewLine or forcePolicyNamePreview are true, let's generate and overwrite the alternate text. */ - const alternateText = getAlternateText(option, {showChatPreviewLine, forcePolicyNamePreview}, !!option.private_isArchived, currentUserAccountID, {}, reportAttributesDerived); + const alternateText = getAlternateText( + option, + {showChatPreviewLine, forcePolicyNamePreview}, + reportPolicyTags, + !!option.private_isArchived, + currentUserAccountID, + {}, + reportAttributesDerived, + ); const isSelected = isReportSelected(option, selectedOptions); let isOptionUnread = option.isUnread; @@ -2197,11 +2243,14 @@ function getRestrictedLogins( /** * Options are reports and personal details. This function filters out the options that are not valid to be displayed. */ +// fix it in the separate issue +// eslint-disable-next-line @typescript-eslint/max-params function getValidOptions( options: OptionList, policiesCollection: OnyxCollection, draftComments: OnyxCollection | undefined, nvpDismissedProductTraining: OnyxEntry, + policyTags: OnyxCollection, loginList: OnyxEntry, currentUserAccountID: number, currentUserEmail: string, @@ -2325,6 +2374,7 @@ function getValidOptions( shouldShowGBR, personalDetails, }, + policyTags, reportAttributesDerived, ).at(0); } @@ -2345,6 +2395,7 @@ function getValidOptions( shouldShowGBR, personalDetails, }, + policyTags, reportAttributesDerived, ); @@ -2361,6 +2412,7 @@ function getValidOptions( shouldShowGBR, personalDetails, }, + policyTags, reportAttributesDerived, ); } else if (recentAttendees && recentAttendees?.length > 0) { @@ -2479,6 +2531,7 @@ type SearchOptionsConfig = { includeCurrentUser?: boolean; countryCode?: number; shouldShowGBR?: boolean; + policyTags: OnyxCollection; shouldUnreadBeBold?: boolean; loginList: OnyxEntry; currentUserAccountID: number; @@ -2495,6 +2548,7 @@ function getSearchOptions({ draftComments, nvpDismissedProductTraining, betas, + policyTags, isUsedInChatFinder = true, includeReadOnly = true, searchQuery = '', @@ -2519,6 +2573,7 @@ function getSearchOptions({ allPolicies, draftComments, nvpDismissedProductTraining, + policyTags, loginList, currentUserAccountID, currentUserEmail, @@ -2672,6 +2727,7 @@ function getMemberInviteOptions( undefined, undefined, nvpDismissedProductTraining, + {}, loginList, currentUserAccountID, currentUserEmail, @@ -2748,6 +2804,7 @@ function formatSectionsFromSearchTerm( selectedOptions: SearchOptionData[], filteredRecentReports: SearchOptionData[], filteredPersonalDetails: SearchOptionData[], + policyTags: OnyxCollection, currentUserAccountID: number, personalDetails: OnyxEntry = {}, shouldGetOptionDetails = false, @@ -2766,7 +2823,7 @@ function formatSectionsFromSearchTerm( ? selectedOptions.map((participant) => { const isReportPolicyExpenseChat = participant.isPolicyExpenseChat ?? false; return isReportPolicyExpenseChat - ? getPolicyExpenseReportOption(participant, currentUserAccountID, personalDetails, reportAttributesDerived) + ? getPolicyExpenseReportOption(participant, policyTags, currentUserAccountID, personalDetails, reportAttributesDerived) : getParticipantsOption(participant, personalDetails); }) : selectedOptions, @@ -2794,7 +2851,7 @@ function formatSectionsFromSearchTerm( ? selectedParticipantsWithoutDetails.map((participant) => { const isReportPolicyExpenseChat = participant.isPolicyExpenseChat ?? false; return isReportPolicyExpenseChat - ? getPolicyExpenseReportOption(participant, currentUserAccountID, personalDetails, reportAttributesDerived) + ? getPolicyExpenseReportOption(participant, policyTags, currentUserAccountID, personalDetails, reportAttributesDerived) : getParticipantsOption(participant, personalDetails); }) : selectedParticipantsWithoutDetails, diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index d7fa27d52e00c..730fcb8195194 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -5,7 +5,17 @@ import type {LocaleContextProps, LocalizedTranslate} from '@components/LocaleCon import type {PartialPolicyForSidebar, ReportsToDisplayInLHN} from '@hooks/useSidebarOrderedReports'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {Card, PersonalDetails, PersonalDetailsList, ReportActions, ReportAttributesDerivedValue, ReportNameValuePairs, Transaction, TransactionViolation} from '@src/types/onyx'; +import type { + Card, + PersonalDetails, + PersonalDetailsList, + PolicyTagLists, + ReportActions, + ReportAttributesDerivedValue, + ReportNameValuePairs, + Transaction, + TransactionViolation, +} from '@src/types/onyx'; import type Beta from '@src/types/onyx/Beta'; import type {ReportAttributes} from '@src/types/onyx/DerivedValues'; import type {Errors} from '@src/types/onyx/OnyxCommon'; @@ -664,12 +674,13 @@ function getOptionData({ invoiceReceiverPolicy, card, lastAction, - translate, localeCompare, isReportArchived, lastActionReport, movedFromReport, movedToReport, + policyTags, + translate, currentUserAccountID, reportAttributesDerived, }: { @@ -682,6 +693,7 @@ function getOptionData({ lastMessageTextFromReport?: string; invoiceReceiverPolicy?: OnyxEntry; reportAttributes: OnyxEntry; + policyTags: OnyxEntry; card: Card | undefined; lastAction: ReportAction | undefined; translate: LocalizedTranslate; @@ -830,6 +842,7 @@ function getOptionData({ movedToReport, policy, isReportArchived, + policyTags, reportAttributesDerived, }); } diff --git a/src/libs/actions/IOU/MoneyRequest.ts b/src/libs/actions/IOU/MoneyRequest.ts index 56f70d79e3199..c6021089e846d 100644 --- a/src/libs/actions/IOU/MoneyRequest.ts +++ b/src/libs/actions/IOU/MoneyRequest.ts @@ -16,7 +16,7 @@ import CONST from '@src/CONST'; import type {TranslationParameters, TranslationPaths} from '@src/languages/types'; import type {Route} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; -import type {Beta, IntroSelected, LastSelectedDistanceRates, PersonalDetailsList, Policy, QuickAction, Report, Transaction, TransactionViolation} from '@src/types/onyx'; +import type {Beta, IntroSelected, LastSelectedDistanceRates, PersonalDetailsList, Policy, PolicyTagLists, QuickAction, Report, Transaction, TransactionViolation} from '@src/types/onyx'; import type {ReportAttributes, ReportAttributesDerivedValue} from '@src/types/onyx/DerivedValues'; import type {Participant} from '@src/types/onyx/IOU'; import type {Receipt, WaypointCollection} from '@src/types/onyx/Transaction'; @@ -98,6 +98,7 @@ type MoneyRequestStepScanParticipantsFlowParams = { activePolicyID?: string; privateIsArchived?: string; files: ReceiptFile[]; + policyTags: OnyxEntry; isTestTransaction?: boolean; locationPermissionGranted?: boolean; shouldGenerateTransactionThreadReport: boolean; @@ -133,6 +134,7 @@ type MoneyRequestStepDistanceNavigationParams = { setDistanceRequestData?: (participants: Participant[]) => void; translate: (path: TPath, ...parameters: TranslationParameters) => string; quickAction: OnyxEntry; + policyTags: OnyxEntry; policyRecentlyUsedCurrencies?: string[]; introSelected?: IntroSelected; activePolicyID?: string; @@ -245,6 +247,7 @@ function getMoneyRequestParticipantOptions( report: OnyxEntry, policy: OnyxEntry, personalDetails: OnyxEntry, + policyTags: OnyxEntry, privateIsArchived?: string, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], ): Array { @@ -253,7 +256,7 @@ function getMoneyRequestParticipantOptions( const participantAccountID = participant?.accountID ?? CONST.DEFAULT_NUMBER_ID; return participantAccountID ? getParticipantsOption(participant, personalDetails) - : getReportOption(participant, privateIsArchived, policy, currentUserAccountID, personalDetails, reportAttributesDerived); + : getReportOption(participant, policyTags, privateIsArchived, policy, currentUserAccountID, personalDetails, reportAttributesDerived); }); } @@ -284,6 +287,7 @@ function handleMoneyRequestStepScanParticipants({ activePolicyID, privateIsArchived, files, + policyTags, isTestTransaction = false, locationPermissionGranted = false, selfDMReport, @@ -322,7 +326,7 @@ function handleMoneyRequestStepScanParticipants({ // to the confirmation step. // If the user is started this flow using the Create expense option (combined submit/track flow), they should be redirected to the participants page. if (!initialTransaction?.isFromGlobalCreate && !isArchivedExpenseReport && iouType !== CONST.IOU.TYPE.CREATE) { - const participants = getMoneyRequestParticipantOptions(currentUserAccountID, report, policy, personalDetails, privateIsArchived, reportAttributesDerived); + const participants = getMoneyRequestParticipantOptions(currentUserAccountID, report, policy, personalDetails, policyTags, privateIsArchived, reportAttributesDerived); if (shouldSkipConfirmation) { const firstReceiptFile = files.at(0); @@ -517,6 +521,7 @@ function handleMoneyRequestStepDistanceNavigation({ quickAction, policyRecentlyUsedCurrencies, introSelected, + policyTags, activePolicyID, privateIsArchived, selfDMReport, @@ -544,7 +549,7 @@ function handleMoneyRequestStepDistanceNavigation({ // to the confirm step. // If the user started this flow using the Create expense option (combined submit/track flow), they should be redirected to the participants page. if (report?.reportID && !isArchivedExpenseReport && iouType !== CONST.IOU.TYPE.CREATE) { - const participants = getMoneyRequestParticipantOptions(currentUserAccountID, report, policy, personalDetails, privateIsArchived, reportAttributesDerived); + const participants = getMoneyRequestParticipantOptions(currentUserAccountID, report, policy, personalDetails, policyTags, privateIsArchived, reportAttributesDerived); let validWaypoints: WaypointCollection | undefined; if (!isManualDistance) { diff --git a/src/pages/NewChatPage.tsx b/src/pages/NewChatPage.tsx index 65eab0f48eeaa..41e0e67c9f351 100755 --- a/src/pages/NewChatPage.tsx +++ b/src/pages/NewChatPage.tsx @@ -70,6 +70,7 @@ function useOptions(reportAttributesDerived: ReportAttributesDerivedValue['repor const [didScreenTransitionEnd, setDidScreenTransitionEnd] = useState(false); const {contacts} = useContactImport(); const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, {canBeMissing: true}); + const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {canBeMissing: false}); const allPersonalDetails = usePersonalDetails(); const { @@ -102,6 +103,7 @@ function useOptions(reportAttributesDerived: ReportAttributesDerivedValue['repor allPolicies, draftComments, nvpDismissedProductTraining, + policyTags, loginList, currentUserAccountID, currentUserEmail, @@ -243,7 +245,7 @@ function NewChatPage({ref}: NewChatPageProps) { const [reportAttributesDerivedFull] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true}); const reportAttributesDerived = reportAttributesDerivedFull?.reports; const selectionListRef = useRef(null); - + const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {canBeMissing: true}); const allPersonalDetails = usePersonalDetails(); const {singleExecution} = useSingleExecution(); @@ -274,6 +276,7 @@ function NewChatPage({ref}: NewChatPageProps) { selectedOptions as OptionData[], recentReports, personalDetails, + policyTags, currentUserAccountID, allPersonalDetails, undefined, diff --git a/src/pages/Share/ShareDetailsPage.tsx b/src/pages/Share/ShareDetailsPage.tsx index a0714904f991a..4be8350f59552 100644 --- a/src/pages/Share/ShareDetailsPage.tsx +++ b/src/pages/Share/ShareDetailsPage.tsx @@ -64,12 +64,13 @@ function ShareDetailsPage({route}: ShareDetailsPageProps) { const [errorMessage, setErrorMessage] = useState(undefined); const report: OnyxEntry = getReportOrDraftReport(reportOrAccountID); + const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report?.policyID}`, {canBeMissing: false}); const privateIsArchivedMap = usePrivateIsArchivedMap(); const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`]; const ancestors = useAncestors(report); const displayReport = useMemo( - () => getReportDisplayOption(report, unknownUserDetails, personalDetail.accountID, personalDetails, privateIsArchived, reportAttributesDerived), - [report, unknownUserDetails, personalDetails, privateIsArchived, reportAttributesDerived, personalDetail.accountID], + () => getReportDisplayOption(report, unknownUserDetails, policyTags, personalDetail.accountID, personalDetails, privateIsArchived, reportAttributesDerived), + [report, unknownUserDetails, policyTags, personalDetail.accountID, personalDetails, privateIsArchived, reportAttributesDerived], ); const shouldShowAttachment = !isTextShared; diff --git a/src/pages/Share/ShareTab.tsx b/src/pages/Share/ShareTab.tsx index 6cd22e3403d46..555c25456dbf5 100644 --- a/src/pages/Share/ShareTab.tsx +++ b/src/pages/Share/ShareTab.tsx @@ -52,6 +52,7 @@ function ShareTab({ref}: ShareTabProps) { const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST, {canBeMissing: true}); const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, {canBeMissing: true}); const [nvpDismissedProductTraining] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {canBeMissing: true}); + const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {canBeMissing: false}); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const currentUserAccountID = currentUserPersonalDetails.accountID; const currentUserEmail = currentUserPersonalDetails.email ?? ''; @@ -82,12 +83,26 @@ function ShareTab({ref}: ShareTabProps) { maxResults: 20, includeUserToInvite: true, countryCode, + policyTags, loginList, currentUserAccountID, currentUserEmail, personalDetails, }); - }, [areOptionsInitialized, options, draftComments, nvpDismissedProductTraining, betas, textInputValue, countryCode, loginList, currentUserAccountID, currentUserEmail, personalDetails]); + }, [ + areOptionsInitialized, + options, + draftComments, + nvpDismissedProductTraining, + betas, + textInputValue, + countryCode, + loginList, + currentUserAccountID, + currentUserEmail, + personalDetails, + policyTags, + ]); const recentReportsOptions = useMemo(() => { if (textInputValue.trim() === '') { diff --git a/src/pages/Share/SubmitDetailsPage.tsx b/src/pages/Share/SubmitDetailsPage.tsx index b9296aa8fe4d1..fb2950773461c 100644 --- a/src/pages/Share/SubmitDetailsPage.tsx +++ b/src/pages/Share/SubmitDetailsPage.tsx @@ -119,7 +119,7 @@ function SubmitDetailsPage({ const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${participant.reportID}`]; return participant?.accountID ? getParticipantsOption(participant, personalDetails) - : getReportOption(participant, privateIsArchived, policy, currentUserPersonalDetails.accountID, personalDetails, reportAttributesDerived); + : getReportOption(participant, policyTags, privateIsArchived, policy, currentUserPersonalDetails.accountID, personalDetails, reportAttributesDerived); }); const trimmedComment = transaction?.comment?.comment?.trim() ?? ''; const transactionAmount = transaction?.amount ?? 0; diff --git a/src/pages/iou/SplitBillDetailsPage.tsx b/src/pages/iou/SplitBillDetailsPage.tsx index 0514229b3257e..9969ea3bc793d 100644 --- a/src/pages/iou/SplitBillDetailsPage.tsx +++ b/src/pages/iou/SplitBillDetailsPage.tsx @@ -66,6 +66,8 @@ function SplitBillDetailsPage({route, report, reportAction}: SplitBillDetailsPag const [quickAction] = useOnyx(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, {canBeMissing: true}); const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false}); const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: reportsSelector}); + const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {canBeMissing: false}); + const [betas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: true}); // In case this is workspace split expense, we manually add the workspace as the second participant of the split expense // because we don't save any accountID in the report action's originalMessage other than the payee's accountID @@ -73,7 +75,7 @@ function SplitBillDetailsPage({route, report, reportAction}: SplitBillDetailsPag if (isPolicyExpenseChat(report)) { participants = [ getParticipantsOption({accountID: participantAccountIDs.at(0), selected: true, reportID: ''}, personalDetails), - getPolicyExpenseReportOption({...report, selected: true, reportID}, currentUserPersonalDetails.accountID, personalDetails, reportAttributesDerived), + getPolicyExpenseReportOption({...report, selected: true, reportID}, policyTags, currentUserPersonalDetails.accountID, personalDetails, reportAttributesDerived), ]; } else { participants = participantAccountIDs.map((accountID) => getParticipantsOption({accountID, selected: true, reportID: ''}, personalDetails)); diff --git a/src/pages/iou/request/MoneyRequestAccountantSelector.tsx b/src/pages/iou/request/MoneyRequestAccountantSelector.tsx index 4bd11762780e4..a9a078f66ebb2 100644 --- a/src/pages/iou/request/MoneyRequestAccountantSelector.tsx +++ b/src/pages/iou/request/MoneyRequestAccountantSelector.tsx @@ -66,6 +66,7 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: reportsSelector}); const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, {canBeMissing: true}); const [nvpDismissedProductTraining] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {canBeMissing: true}); + const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {canBeMissing: false}); const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST, {canBeMissing: true}); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const currentUserEmail = currentUserPersonalDetails.email ?? ''; @@ -89,6 +90,7 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType allPolicies, draftComments, nvpDismissedProductTraining, + policyTags, loginList, currentUserAccountID, currentUserEmail, @@ -115,6 +117,7 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType allPolicies, draftComments, nvpDismissedProductTraining, + policyTags, loginList, betas, action, @@ -158,6 +161,7 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType [], chatOptions.recentReports, chatOptions.personalDetails, + policyTags, currentUserAccountID, personalDetails, true, @@ -193,7 +197,7 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType data: [chatOptions.userToInvite].map((participant) => { const isPolicyExpenseChat = participant?.isPolicyExpenseChat ?? false; return isPolicyExpenseChat - ? getPolicyExpenseReportOption(participant, currentUserAccountID, personalDetails, reportAttributesDerived) + ? getPolicyExpenseReportOption(participant, policyTags, currentUserAccountID, personalDetails, reportAttributesDerived) : getParticipantsOption(participant, personalDetails); }), shouldShow: true, @@ -216,9 +220,10 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType chatOptions.personalDetails, chatOptions.userToInvite, debouncedSearchTerm, + policyTags, + translate, personalDetails, reportAttributesDerived, - translate, loginList, countryCode, currentUserAccountID, diff --git a/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx b/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx index ee83c80b547af..1fb7d7386ad78 100644 --- a/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx +++ b/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx @@ -68,6 +68,7 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde const policy = usePolicy(activePolicyID); const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false, canBeMissing: true}); const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: reportsSelector}); + const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}`, {canBeMissing: true}); const offlineMessage: string = isOffline ? `${translate('common.youAppearToBeOffline')} ${translate('search.resultsAreLimited')}` : ''; const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST, {canBeMissing: true}); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); @@ -217,6 +218,7 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde initialSelectedOptions, orderedAvailableOptions.recentReports, orderedAvailableOptions.personalDetails, + policyTags, currentUserAccountID, personalDetails, true, @@ -260,7 +262,7 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde data: [orderedAvailableOptions.userToInvite].map((participant) => { const isPolicyExpenseChat = participant?.isPolicyExpenseChat ?? false; return isPolicyExpenseChat - ? getPolicyExpenseReportOption(participant, currentUserAccountID, personalDetails, reportAttributesDerived) + ? getPolicyExpenseReportOption(participant, policyTags, currentUserAccountID, personalDetails, reportAttributesDerived) : getParticipantsOption(participant, personalDetails); }) as OptionData[], shouldShow: true, @@ -281,17 +283,18 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde didScreenTransitionEnd, searchTerm, initialSelectedOptions, - attendees, orderedAvailableOptions.recentReports, orderedAvailableOptions.personalDetails, orderedAvailableOptions.userToInvite, + policyTags, + currentUserAccountID, personalDetails, reportAttributesDerived, loginList, + currentUserEmail, countryCode, + attendees, translate, - currentUserAccountID, - currentUserEmail, ]); const optionLength = useMemo(() => { diff --git a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx index 808b0af2e6c3b..6ce9131fa63d5 100644 --- a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx +++ b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx @@ -123,6 +123,7 @@ function MoneyRequestParticipantsSelector({ const currentUserAccountID = currentUserPersonalDetails.accountID; const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: reportsSelector}); const [countryCode = CONST.DEFAULT_COUNTRY_CODE] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false}); + const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}`, {canBeMissing: true}); const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST, {canBeMissing: true}); const [textInputAutoFocus, setTextInputAutoFocus] = useState(!isNative); @@ -291,6 +292,7 @@ function MoneyRequestParticipantsSelector({ participants.map((participant) => ({...participant, reportID: participant.reportID})) as OptionData[], [], [], + policyTags, currentUserAccountID, personalDetails, true, @@ -346,7 +348,7 @@ function MoneyRequestParticipantsSelector({ data: [availableOptions.userToInvite].map((participant) => { const isPolicyExpenseChat = participant?.isPolicyExpenseChat ?? false; return isPolicyExpenseChat - ? getPolicyExpenseReportOption(participant, currentUserAccountID, personalDetails, reportAttributesDerived) + ? getPolicyExpenseReportOption(participant, policyTags, currentUserAccountID, personalDetails, reportAttributesDerived) : getParticipantsOption(participant, personalDetails); }), shouldShow: true, @@ -364,6 +366,8 @@ function MoneyRequestParticipantsSelector({ didScreenTransitionEnd, searchTerm, participants, + policyTags, + currentUserAccountID, personalDetails, reportAttributesDerived, translate, @@ -374,11 +378,10 @@ function MoneyRequestParticipantsSelector({ availableOptions.personalDetails, isWorkspacesOnly, loginList, + currentUserEmail, isPerDiemRequest, showImportContacts, inputHelperText, - currentUserAccountID, - currentUserEmail, ]); /** diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 1cf5a5dc3ac99..0e86928d7b644 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -93,6 +93,7 @@ function IOURequestStepAmount({ const selfDMReport = useSelfDMReport(); const isReportArchived = useReportIsArchived(report?.reportID); const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {canBeMissing: true}); + const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, {canBeMissing: false}); const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`, {canBeMissing: true}); const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(report?.parentReportID)}`, {canBeMissing: true}); const [parentReportNextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${getNonEmptyStringOnyxID(report?.parentReportID)}`, {canBeMissing: true}); @@ -225,7 +226,7 @@ function IOURequestStepAmount({ const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${participant.reportID}`]; return participantAccountID ? getParticipantsOption(participant, personalDetails) - : getReportOption(participant, privateIsArchived, policy, currentUserAccountIDParam, personalDetails, reportAttributesDerived); + : getReportOption(participant, policyTags, privateIsArchived, policy, currentUserAccountIDParam, personalDetails, reportAttributesDerived); }); const backendAmount = convertToBackendAmount(Number.parseFloat(amount)); diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 2bc7ba1cb0608..58cf0ad53e4d5 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -298,9 +298,9 @@ function IOURequestStepConfirmation({ const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${participant.reportID}`]; return participant.accountID ? getParticipantsOption(participant, personalDetails) - : getReportOption(participant, privateIsArchived, policy, currentUserPersonalDetails.accountID, personalDetails, reportAttributesDerived, reportDrafts); + : getReportOption(participant, policyTags, privateIsArchived, policy, currentUserPersonalDetails.accountID, personalDetails, reportAttributesDerived, reportDrafts); }) ?? [], - [transaction?.participants, iouType, personalDetails, reportAttributesDerived, reportDrafts, privateIsArchivedMap, policy, currentUserPersonalDetails.accountID], + [transaction?.participants, iouType, privateIsArchivedMap, personalDetails, policyTags, policy, currentUserPersonalDetails.accountID, reportAttributesDerived, reportDrafts], ); const isPolicyExpenseChat = useMemo(() => participants?.some((participant) => participant.isPolicyExpenseChat), [participants]); const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS); @@ -1175,6 +1175,7 @@ function IOURequestStepConfirmation({ policyRecentlyUsedCategories, policyRecentlyUsedTags, quickAction, + policyRecentlyUsedCurrencies, isASAPSubmitBetaEnabled, transactionViolations, receiverParticipantAccountID, @@ -1185,7 +1186,6 @@ function IOURequestStepConfirmation({ trackExpense, userLocation, submitPerDiemExpense, - policyRecentlyUsedCurrencies, reportID, betas, ], diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index c1d594b05c0c4..df453180abc2b 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -323,6 +323,7 @@ function IOURequestStepDistance({ introSelected, activePolicyID, privateIsArchived: reportNameValuePairs?.private_isArchived, + policyTags, selfDMReport, policyForMovingExpenses, betas, @@ -332,7 +333,6 @@ function IOURequestStepDistance({ report, policy, transaction, - reportID, transactionID, reportAttributesDerived, personalDetails, @@ -345,7 +345,6 @@ function IOURequestStepDistance({ shouldSkipConfirmation, defaultExpensePolicy, isArchived, - personalPolicy?.autoReporting, isASAPSubmitBetaEnabled, transactionViolations, lastSelectedDistanceRates, @@ -358,8 +357,10 @@ function IOURequestStepDistance({ reportNameValuePairs?.private_isArchived, policyForMovingExpenses, selfDMReport, - reportNameValuePairs?.private_isArchived, betas, + policyTags, + personalPolicy?.autoReporting, + reportID, ]); const getError = () => { diff --git a/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.native.tsx b/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.native.tsx index a507a4a06a20f..e0a04c1a09adf 100644 --- a/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.native.tsx @@ -66,6 +66,7 @@ function IOURequestStepDistanceGPS({ const personalPolicy = usePersonalPolicy(); const policy = usePolicy(report?.policyID); const isArchived = isArchivedReport(reportNameValuePairs); + const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policy?.id}`, {canBeMissing: true}); const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); @@ -117,6 +118,7 @@ function IOURequestStepDistanceGPS({ privateIsArchived: reportNameValuePairs?.private_isArchived, gpsCoordinates, gpsDistance: distance, + policyTags, selfDMReport, policyForMovingExpenses, betas, diff --git a/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx b/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx index 33886d82aaad8..1b2498f64bac0 100644 --- a/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx @@ -206,6 +206,7 @@ function IOURequestStepDistanceManual({ introSelected, activePolicyID, privateIsArchived: reportNameValuePairs?.private_isArchived, + policyTags, selfDMReport, policyForMovingExpenses, betas, diff --git a/src/pages/iou/request/step/IOURequestStepDistanceMap.tsx b/src/pages/iou/request/step/IOURequestStepDistanceMap.tsx index bdf18091fa1a1..b1a6cfa83e6fb 100644 --- a/src/pages/iou/request/step/IOURequestStepDistanceMap.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistanceMap.tsx @@ -319,6 +319,7 @@ function IOURequestStepDistanceMap({ policyRecentlyUsedCurrencies, introSelected, activePolicyID, + policyTags, privateIsArchived: reportNameValuePairs?.private_isArchived, selfDMReport, policyForMovingExpenses, @@ -352,7 +353,7 @@ function IOURequestStepDistanceMap({ policyRecentlyUsedCurrencies, introSelected, activePolicyID, - reportNameValuePairs?.private_isArchived, + policyTags, policyForMovingExpenses, selfDMReport, reportNameValuePairs?.private_isArchived, @@ -454,22 +455,22 @@ function IOURequestStepDistanceMap({ navigateToNextStep(); }, [ - atLeastTwoDifferentWaypointsError, - currentUserAccountIDParam, - currentUserEmailParam, duplicateWaypointsError, + atLeastTwoDifferentWaypointsError, hasRouteError, - isASAPSubmitBetaEnabled, - isCreatingNewRequest, + isLoadingRoute, isEditing, isLoading, - isLoadingRoute, - navigateBack, + isCreatingNewRequest, navigateToNextStep, + navigateBack, parentReport, policy, policyTags, policyCategories, + currentUserAccountIDParam, + currentUserEmailParam, + isASAPSubmitBetaEnabled, report, transaction?.routes, transaction?.transactionID, diff --git a/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx b/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx index a350b7f7ff0b6..d0927ad39f5c3 100644 --- a/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx @@ -405,7 +405,7 @@ function IOURequestStepDistanceOdometer({ const participantAccountID = participant?.accountID ?? CONST.DEFAULT_NUMBER_ID; return participantAccountID ? getParticipantsOption(participant, personalDetails) - : getReportOption(participant, reportNameValuePairs?.private_isArchived, policy, currentUserPersonalDetails.accountID, personalDetails, derivedReports); + : getReportOption(participant, policyTags, reportNameValuePairs?.private_isArchived, policy, currentUserPersonalDetails.accountID, personalDetails, derivedReports); }); if (shouldSkipConfirmation) { diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index d3f200affac30..11ad151600a16 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -121,6 +121,7 @@ function IOURequestStepScan({ const [policyRecentlyUsedCurrencies] = useOnyx(ONYXKEYS.RECENTLY_USED_CURRENCIES, {canBeMissing: true}); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true}); + const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report?.policyID}`, {canBeMissing: true}); const [isSelfTourViewed = false] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {canBeMissing: true, selector: hasSeenTourSelector}); const [betas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: true}); const defaultTaxCode = getDefaultTaxCode(policy, initialTransaction); @@ -293,6 +294,7 @@ function IOURequestStepScan({ files, isTestTransaction, locationPermissionGranted, + policyTags, selfDMReport, isSelfTourViewed, betas, @@ -300,37 +302,38 @@ function IOURequestStepScan({ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- reportNameValuePairs?.private_isArchived is not needed [ - backTo, - backToReport, - shouldGenerateTransactionThreadReport, - transactions, - initialTransaction?.isFromGlobalCreate, - initialTransaction?.currency, - initialTransaction?.participants, - initialTransaction?.reportID, - isArchived, iouType, - defaultExpensePolicy, + policy, report, - initialTransactionID, - currentUserPersonalDetails.accountID, - currentUserPersonalDetails?.login, - shouldSkipConfirmation, - personalDetails, - reportAttributesDerived, reportID, + reportAttributesDerived, + transactions, + initialTransactionID, + initialTransaction?.reportID, + initialTransaction?.currency, + initialTransaction?.isFromGlobalCreate, + initialTransaction?.participants, transactionTaxCode, transactionTaxAmount, - quickAction, - policy, + personalDetails, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, + backTo, + backToReport, + shouldSkipConfirmation, + defaultExpensePolicy, + shouldGenerateTransactionThreadReport, + isArchived, personalPolicy?.autoReporting, selfDMReport, isASAPSubmitBetaEnabled, transactionViolations, + quickAction, policyRecentlyUsedCurrencies, introSelected, activePolicyID, reportNameValuePairs?.private_isArchived, + policyTags, isSelfTourViewed, betas, ], @@ -558,6 +561,7 @@ function IOURequestStepScan({ cameraPermissionStatus, didCapturePhoto, isMultiScanEnabled, + askForPermissions, translate, showBlink, flash, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index a6e592728eef3..f963c4cacc4bc 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -118,6 +118,7 @@ function IOURequestStepScan({ const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: true}); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true}); + const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report?.policyID}`, {canBeMissing: true}); const [isSelfTourViewed = false] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {canBeMissing: true, selector: hasSeenTourSelector}); const [betas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: true}); const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${report?.policyID}`, {canBeMissing: true}); @@ -346,6 +347,7 @@ function IOURequestStepScan({ files, isTestTransaction, locationPermissionGranted, + policyTags, selfDMReport, policyForMovingExpenses, isSelfTourViewed, @@ -384,6 +386,7 @@ function IOURequestStepScan({ introSelected, activePolicyID, reportNameValuePairs?.private_isArchived, + policyTags, policyForMovingExpenses, isSelfTourViewed, betas, diff --git a/src/pages/workspace/WorkspaceMembersPage.tsx b/src/pages/workspace/WorkspaceMembersPage.tsx index c3468a9f8fde1..ba99baa3b4de1 100644 --- a/src/pages/workspace/WorkspaceMembersPage.tsx +++ b/src/pages/workspace/WorkspaceMembersPage.tsx @@ -483,12 +483,13 @@ function WorkspaceMembersPage({personalDetails, route, policy}: WorkspaceMembers return result; }, [ policy?.employeeList, - policy?.ownerAccountID, policy?.owner, + policy?.ownerAccountID, policyMemberEmailsToAccountIDs, isOffline, personalDetails, isPolicyAdmin, + formatPhoneNumber, session?.accountID, styles.cursorDefault, styles.flex1, @@ -498,11 +499,10 @@ function WorkspaceMembersPage({personalDetails, route, policy}: WorkspaceMembers styles.alignSelfEnd, isControlPolicyWithWideLayout, StyleUtils, - formatPhoneNumber, + icons.FallbackAvatar, invitedPrimaryToSecondaryLogins, policyOwner, currentUserLogin, - icons.FallbackAvatar, ]); const filterMember = useCallback((memberOption: MemberOption, searchQuery: string) => { diff --git a/tests/actions/IOU/MoneyRequestTest.ts b/tests/actions/IOU/MoneyRequestTest.ts index b952aca83ea80..4d2dab18054a7 100644 --- a/tests/actions/IOU/MoneyRequestTest.ts +++ b/tests/actions/IOU/MoneyRequestTest.ts @@ -299,6 +299,7 @@ describe('MoneyRequest', () => { quickAction: fakeQuickAction, files: [fakeReceiptFile], shouldGenerateTransactionThreadReport: false, + policyTags: {}, selfDMReport, isSelfTourViewed: false, betas: [], @@ -734,6 +735,7 @@ describe('MoneyRequest', () => { setDistanceRequestData: jest.fn(), translate: jest.fn().mockReturnValue('Pending...'), quickAction: fakeQuickAction, + policyTags: {}, selfDMReport, betas: [CONST.BETAS.ALL], }; diff --git a/tests/perf-test/OptionsListUtils.perf-test.ts b/tests/perf-test/OptionsListUtils.perf-test.ts index afe59a3d1fc20..2f8e2e039d933 100644 --- a/tests/perf-test/OptionsListUtils.perf-test.ts +++ b/tests/perf-test/OptionsListUtils.perf-test.ts @@ -95,7 +95,7 @@ jest.mock('@react-navigation/native', () => { }); const EMPTY_PRIVATE_IS_ARCHIVED_MAP: PrivateIsArchivedMap = {}; -const options = createOptionList(personalDetails, MOCK_CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, reports); +const options = createOptionList(personalDetails, undefined, MOCK_CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, reports); const ValidOptionsConfig = { betas: mockedBetas, @@ -139,6 +139,7 @@ describe('OptionsListUtils', () => { loginList, currentUserAccountID: MOCK_CURRENT_USER_ACCOUNT_ID, currentUserEmail: MOCK_CURRENT_USER_EMAIL, + policyTags: undefined, personalDetails, }), ); @@ -152,6 +153,7 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, loginList, MOCK_CURRENT_USER_ACCOUNT_ID, MOCK_CURRENT_USER_EMAIL, @@ -168,6 +170,7 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, loginList, MOCK_CURRENT_USER_ACCOUNT_ID, MOCK_CURRENT_USER_EMAIL, @@ -187,6 +190,7 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, loginList, MOCK_CURRENT_USER_ACCOUNT_ID, MOCK_CURRENT_USER_EMAIL, @@ -268,6 +272,7 @@ describe('OptionsListUtils', () => { Object.values(selectedOptions), Object.values(filteredRecentReports), Object.values(filteredPersonalDetails), + undefined, MOCK_CURRENT_USER_ACCOUNT_ID, mockedPersonalDetails, true, @@ -281,6 +286,6 @@ describe('OptionsListUtils', () => { const mockedPersonalDetails = getMockedPersonalDetails(PERSONAL_DETAILS_COUNT); await waitForBatchedUpdates(); - await measureFunction(() => formatSectionsFromSearchTerm('', Object.values(selectedOptions), [], [], MOCK_CURRENT_USER_ACCOUNT_ID, mockedPersonalDetails, true)); + await measureFunction(() => formatSectionsFromSearchTerm('', Object.values(selectedOptions), [], [], undefined, MOCK_CURRENT_USER_ACCOUNT_ID, mockedPersonalDetails, true)); }); }); diff --git a/tests/perf-test/SearchRouter.perf-test.tsx b/tests/perf-test/SearchRouter.perf-test.tsx index 9c75755c2fb80..b0a054309c7ac 100644 --- a/tests/perf-test/SearchRouter.perf-test.tsx +++ b/tests/perf-test/SearchRouter.perf-test.tsx @@ -44,6 +44,17 @@ jest.mock('@src/libs/Navigation/Navigation', () => ({ isDisplayedInModal: jest.fn(() => false), })); +// Mock useRootNavigationState to return a stable value + +// Mock useLazyAsset hook to prevent async loading causing extra renders +// Must include all icons used by SearchRouter and its children (SearchAutocompleteList) +jest.mock('@hooks/useLazyAsset', () => ({ + useMemoizedLazyExpensifyIcons: jest.fn(() => ({ + MagnifyingGlass: 'MagnifyingGlass', + History: 'History', + })), +})); + jest.mock('@src/hooks/useRootNavigationState', () => ({ // eslint-disable-next-line @typescript-eslint/naming-convention __esModule: true, @@ -97,7 +108,7 @@ const mockedReports = getMockedReports(600); const mockedBetas = Object.values(CONST.BETAS); const mockedPersonalDetails = getMockedPersonalDetails(100); const EMPTY_PRIVATE_IS_ARCHIVED_MAP: PrivateIsArchivedMap = {}; -const mockedOptions = createOptionList(mockedPersonalDetails, MOCK_CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, mockedReports); +const mockedOptions = createOptionList(mockedPersonalDetails, undefined, MOCK_CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, mockedReports); beforeAll(() => Onyx.init({ diff --git a/tests/perf-test/SidebarUtils.perf-test.ts b/tests/perf-test/SidebarUtils.perf-test.ts index ab45ab1c4642c..134a0a8afd507 100644 --- a/tests/perf-test/SidebarUtils.perf-test.ts +++ b/tests/perf-test/SidebarUtils.perf-test.ts @@ -90,6 +90,7 @@ describe('SidebarUtils', () => { localeCompare, lastActionReport: undefined, isReportArchived: undefined, + policyTags: undefined, currentUserAccountID: 1, }), ); diff --git a/tests/unit/OptionsListUtilsTest.tsx b/tests/unit/OptionsListUtilsTest.tsx index 3c146a3cf6170..02baec77e8f68 100644 --- a/tests/unit/OptionsListUtilsTest.tsx +++ b/tests/unit/OptionsListUtilsTest.tsx @@ -648,6 +648,7 @@ describe('OptionsListUtils', () => { const loginList = {}; const CURRENT_USER_ACCOUNT_ID = 2; const CURRENT_USER_EMAIL = 'tonystark@expensify.com'; + const POLICY_TAGS = {}; const reportNameValuePairs = { private_isArchived: DateUtils.getDBTime(), @@ -750,9 +751,10 @@ describe('OptionsListUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}10`, reportNameValuePairs); await waitForBatchedUpdates(); - OPTIONS = createOptionList(PERSONAL_DETAILS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS, MOCK_REPORT_ATTRIBUTES_DERIVED); + OPTIONS = createOptionList(PERSONAL_DETAILS, POLICY_TAGS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS, MOCK_REPORT_ATTRIBUTES_DERIVED); OPTIONS_WITH_CONCIERGE = createOptionList( PERSONAL_DETAILS_WITH_CONCIERGE, + POLICY_TAGS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS_WITH_CONCIERGE, @@ -760,6 +762,7 @@ describe('OptionsListUtils', () => { ); OPTIONS_WITH_CHRONOS = createOptionList( PERSONAL_DETAILS_WITH_CHRONOS, + POLICY_TAGS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS_WITH_CHRONOS, @@ -767,6 +770,7 @@ describe('OptionsListUtils', () => { ); OPTIONS_WITH_RECEIPTS = createOptionList( PERSONAL_DETAILS_WITH_RECEIPTS, + POLICY_TAGS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS_WITH_RECEIPTS, @@ -774,6 +778,7 @@ describe('OptionsListUtils', () => { ); OPTIONS_WITH_WORKSPACE_ROOM = createOptionList( PERSONAL_DETAILS, + POLICY_TAGS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS_WITH_WORKSPACE_ROOMS, @@ -781,6 +786,7 @@ describe('OptionsListUtils', () => { ); OPTIONS_WITH_MANAGER_MCTEST = createOptionList( PERSONAL_DETAILS_WITH_MANAGER_MCTEST, + POLICY_TAGS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS_WITH_MANAGER_MCTEST, @@ -797,6 +803,7 @@ describe('OptionsListUtils', () => { reportAttributesDerived: MOCK_REPORT_ATTRIBUTES_DERIVED, draftComments: {}, nvpDismissedProductTraining, + policyTags: POLICY_TAGS, loginList, betas: [CONST.BETAS.ALL], currentUserAccountID: CURRENT_USER_ACCOUNT_ID, @@ -826,6 +833,7 @@ describe('OptionsListUtils', () => { includeUserToInvite: false, includeRecentReports: true, includeCurrentUser: true, + policyTags: POLICY_TAGS, loginList, currentUserAccountID: CURRENT_USER_ACCOUNT_ID, currentUserEmail: CURRENT_USER_EMAIL, @@ -856,6 +864,7 @@ describe('OptionsListUtils', () => { maxResults: undefined, includeUserToInvite: false, includeRecentReports: true, + policyTags: POLICY_TAGS, loginList, currentUserAccountID: CURRENT_USER_ACCOUNT_ID, currentUserEmail: CURRENT_USER_EMAIL, @@ -883,6 +892,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -922,6 +933,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -952,7 +965,17 @@ 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, + undefined, + + loginList, + CURRENT_USER_ACCOUNT_ID, + CURRENT_USER_EMAIL, + ); // Then the result should be empty expect(results.personalDetails).toEqual([]); @@ -971,6 +994,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -993,6 +1018,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1015,6 +1042,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1040,6 +1069,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1067,6 +1098,8 @@ describe('OptionsListUtils', () => { timestamp: DateUtils.getDBTime(new Date().valueOf()), }, }, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1091,6 +1124,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1124,6 +1159,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1181,6 +1218,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1235,6 +1274,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1287,6 +1328,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1343,6 +1386,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1378,6 +1423,8 @@ describe('OptionsListUtils', () => { {}, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1397,12 +1444,23 @@ 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, { - includeRecentReports: true, - includeMultipleParticipantReports: true, - includeP2P: true, - includeOwnedWorkspaceChats: true, - }); + const results = getValidOptions( + OPTIONS_WITH_WORKSPACE_ROOM, + allPolicies, + {}, + nvpDismissedProductTraining, + undefined, + + loginList, + CURRENT_USER_ACCOUNT_ID, + CURRENT_USER_EMAIL, + { + includeRecentReports: true, + includeMultipleParticipantReports: true, + includeP2P: true, + includeOwnedWorkspaceChats: true, + }, + ); // Then the result should include all reports except the currently logged in user expect(results.recentReports.length).toBe(OPTIONS_WITH_WORKSPACE_ROOM.reports.length - 1); @@ -1419,6 +1477,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1440,6 +1500,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1461,6 +1523,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1483,6 +1547,8 @@ describe('OptionsListUtils', () => { undefined, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1506,6 +1572,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1532,6 +1600,8 @@ describe('OptionsListUtils', () => { undefined, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1556,6 +1626,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1576,6 +1648,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1585,6 +1659,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1605,6 +1681,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1614,6 +1692,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1636,6 +1716,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1670,6 +1752,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1711,6 +1795,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -1949,6 +2035,7 @@ describe('OptionsListUtils', () => { reportAttributesDerived: MOCK_REPORT_ATTRIBUTES_DERIVED, draftComments: {}, nvpDismissedProductTraining, + policyTags: POLICY_TAGS, loginList, betas: [CONST.BETAS.ALL], currentUserAccountID: CURRENT_USER_ACCOUNT_ID, @@ -1972,6 +2059,7 @@ describe('OptionsListUtils', () => { draftComments: {}, nvpDismissedProductTraining, loginList, + policyTags: POLICY_TAGS, betas: [CONST.BETAS.ALL], currentUserAccountID: CURRENT_USER_ACCOUNT_ID, currentUserEmail: CURRENT_USER_EMAIL, @@ -2003,6 +2091,8 @@ describe('OptionsListUtils', () => { draftComments: {}, nvpDismissedProductTraining, loginList, + policyTags: POLICY_TAGS, + betas: [CONST.BETAS.ALL], currentUserAccountID: CURRENT_USER_ACCOUNT_ID, currentUserEmail: CURRENT_USER_EMAIL, @@ -2027,6 +2117,8 @@ describe('OptionsListUtils', () => { draftComments: {}, nvpDismissedProductTraining, loginList, + policyTags: POLICY_TAGS, + betas: [CONST.BETAS.ALL], currentUserAccountID: CURRENT_USER_ACCOUNT_ID, currentUserEmail: CURRENT_USER_EMAIL, @@ -2045,12 +2137,14 @@ describe('OptionsListUtils', () => { // cspell:disable-next-line const searchText = 'barryallen'; // Given a set of options created from PERSONAL_DETAILS_WITH_PERIODS - const OPTIONS_WITH_PERIODS = createOptionList(PERSONAL_DETAILS_WITH_PERIODS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS); + const OPTIONS_WITH_PERIODS = createOptionList(PERSONAL_DETAILS_WITH_PERIODS, POLICY_TAGS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS); // When we call getSearchOptions with all betas const options = getSearchOptions({ options: OPTIONS_WITH_PERIODS, draftComments: {}, nvpDismissedProductTraining, + policyTags: POLICY_TAGS, + loginList, betas: [CONST.BETAS.ALL], currentUserAccountID: CURRENT_USER_ACCOUNT_ID, @@ -2076,6 +2170,8 @@ describe('OptionsListUtils', () => { options: OPTIONS_WITH_WORKSPACE_ROOM, draftComments: {}, nvpDismissedProductTraining, + policyTags: POLICY_TAGS, + loginList, betas: [CONST.BETAS.ALL], currentUserAccountID: CURRENT_USER_ACCOUNT_ID, @@ -2099,6 +2195,7 @@ describe('OptionsListUtils', () => { reportAttributesDerived: MOCK_REPORT_ATTRIBUTES_DERIVED, draftComments: {}, nvpDismissedProductTraining, + policyTags: POLICY_TAGS, loginList, betas: [CONST.BETAS.ALL], currentUserAccountID: CURRENT_USER_ACCOUNT_ID, @@ -2120,6 +2217,7 @@ describe('OptionsListUtils', () => { const MOCK_REPORT_ATTRIBUTES_DERIVED_WITH_CHAT_ROOM = createMockReportAttributesDerived(REPORTS_WITH_CHAT_ROOM, PERSONAL_DETAILS, CURRENT_USER_ACCOUNT_ID); const OPTIONS_WITH_CHAT_ROOMS = createOptionList( PERSONAL_DETAILS, + POLICY_TAGS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS_WITH_CHAT_ROOM, @@ -2130,6 +2228,8 @@ describe('OptionsListUtils', () => { options: OPTIONS_WITH_CHAT_ROOMS, draftComments: {}, nvpDismissedProductTraining, + policyTags: POLICY_TAGS, + loginList, betas: [CONST.BETAS.ALL], currentUserAccountID: CURRENT_USER_ACCOUNT_ID, @@ -2154,6 +2254,8 @@ describe('OptionsListUtils', () => { reportAttributesDerived: MOCK_REPORT_ATTRIBUTES_DERIVED, draftComments: {}, nvpDismissedProductTraining, + policyTags: POLICY_TAGS, + loginList, currentUserAccountID: CURRENT_USER_ACCOUNT_ID, currentUserEmail: CURRENT_USER_EMAIL, @@ -2177,6 +2279,8 @@ describe('OptionsListUtils', () => { options: OPTIONS, reportAttributesDerived: MOCK_REPORT_ATTRIBUTES_DERIVED, draftComments: {}, + policyTags: POLICY_TAGS, + loginList, nvpDismissedProductTraining, currentUserAccountID: CURRENT_USER_ACCOUNT_ID, @@ -2198,6 +2302,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -2225,6 +2331,7 @@ describe('OptionsListUtils', () => { nvpDismissedProductTraining, currentUserAccountID: CURRENT_USER_ACCOUNT_ID, currentUserEmail: CURRENT_USER_EMAIL, + policyTags: POLICY_TAGS, personalDetails: PERSONAL_DETAILS, }); // When we call filterAndOrderOptions with a search value and excludeLogins @@ -2247,6 +2354,7 @@ describe('OptionsListUtils', () => { nvpDismissedProductTraining, currentUserAccountID: CURRENT_USER_ACCOUNT_ID, currentUserEmail: CURRENT_USER_EMAIL, + policyTags: POLICY_TAGS, personalDetails: PERSONAL_DETAILS, }); // When we call filterAndOrderOptions with a search value and maxRecentReportsToShow set to 2 @@ -2279,6 +2387,7 @@ describe('OptionsListUtils', () => { betas: [CONST.BETAS.ALL], currentUserAccountID: CURRENT_USER_ACCOUNT_ID, currentUserEmail: CURRENT_USER_EMAIL, + policyTags: POLICY_TAGS, personalDetails: PERSONAL_DETAILS, }); // When we call filterAndOrderOptions with a search value @@ -2327,6 +2436,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -2369,6 +2480,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -2411,6 +2524,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -2443,6 +2558,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -2477,7 +2594,7 @@ describe('OptionsListUtils', () => { }, }; - const OPTIONS_WITH_GROUP_CHAT = createOptionList(PERSONAL_DETAILS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS_WITH_GROUP_CHAT); + const OPTIONS_WITH_GROUP_CHAT = createOptionList(PERSONAL_DETAILS, POLICY_TAGS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS_WITH_GROUP_CHAT); // When we call getSearchOptions with a search query that matches a participant display name const options = getSearchOptions({ @@ -2490,6 +2607,7 @@ describe('OptionsListUtils', () => { currentUserEmail: CURRENT_USER_EMAIL, personalDetails: PERSONAL_DETAILS, searchQuery: 'Spider-Man', + policyTags: POLICY_TAGS, }); // Then one report should be returned @@ -2517,7 +2635,7 @@ describe('OptionsListUtils', () => { }, }; - const OPTIONS_WITH_GROUP_CHAT = createOptionList(PERSONAL_DETAILS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS_WITH_GROUP_CHAT); + const OPTIONS_WITH_GROUP_CHAT = createOptionList(PERSONAL_DETAILS, POLICY_TAGS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS_WITH_GROUP_CHAT); // When we call getSearchOptions with a search query that matches a participant login const options = getSearchOptions({ @@ -2530,6 +2648,7 @@ describe('OptionsListUtils', () => { currentUserEmail: CURRENT_USER_EMAIL, personalDetails: PERSONAL_DETAILS, searchQuery: 'peterparker@expensify.com', + policyTags: POLICY_TAGS, }); // Then one report should be returned @@ -2557,7 +2676,7 @@ describe('OptionsListUtils', () => { }, }; - const OPTIONS_WITH_GROUP_CHAT = createOptionList(PERSONAL_DETAILS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS_WITH_GROUP_CHAT); + const OPTIONS_WITH_GROUP_CHAT = createOptionList(PERSONAL_DETAILS, POLICY_TAGS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS_WITH_GROUP_CHAT); // When we call getSearchOptions with a search query that matches a participant name const options = getSearchOptions({ @@ -2570,6 +2689,7 @@ describe('OptionsListUtils', () => { currentUserEmail: CURRENT_USER_EMAIL, personalDetails: PERSONAL_DETAILS, searchQuery: 'Black Panther', + policyTags: POLICY_TAGS, }); // Then one report should be returned @@ -2597,7 +2717,7 @@ describe('OptionsListUtils', () => { }, }; - const OPTIONS_WITH_GROUP_CHAT = createOptionList(PERSONAL_DETAILS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS_WITH_GROUP_CHAT); + const OPTIONS_WITH_GROUP_CHAT = createOptionList(PERSONAL_DETAILS, POLICY_TAGS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS_WITH_GROUP_CHAT); // When we call getSearchOptions with a search query that does not match any participant const options = getSearchOptions({ @@ -2610,6 +2730,7 @@ describe('OptionsListUtils', () => { currentUserEmail: CURRENT_USER_EMAIL, personalDetails: PERSONAL_DETAILS, searchQuery: 'Wolverine', + policyTags: POLICY_TAGS, }); // Then no reports should be returned @@ -2636,6 +2757,7 @@ describe('OptionsListUtils', () => { const OPTIONS_WITH_GROUP_CHAT_NO_PARTICIPANTS = createOptionList( PERSONAL_DETAILS, + POLICY_TAGS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS_WITH_GROUP_CHAT_NO_PARTICIPANTS, @@ -2651,6 +2773,7 @@ describe('OptionsListUtils', () => { currentUserAccountID: CURRENT_USER_ACCOUNT_ID, currentUserEmail: CURRENT_USER_EMAIL, personalDetails: PERSONAL_DETAILS, + policyTags: POLICY_TAGS, }); // When we pass the returned options to filterAndOrderOptions with any search value @@ -2668,6 +2791,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -2689,6 +2814,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -2710,6 +2837,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -2730,6 +2859,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -2748,6 +2879,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -2771,6 +2904,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -2794,6 +2929,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -2817,6 +2954,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -2839,6 +2978,7 @@ describe('OptionsListUtils', () => { {}, nvpDismissedProductTraining, loginList, + {}, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, { @@ -2863,6 +3003,7 @@ describe('OptionsListUtils', () => { {}, nvpDismissedProductTraining, loginList, + {}, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, { @@ -2886,6 +3027,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -2904,6 +3047,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -2928,6 +3073,8 @@ describe('OptionsListUtils', () => { allPolicies, {}, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -2958,6 +3105,7 @@ describe('OptionsListUtils', () => { loginList, currentUserAccountID: CURRENT_USER_ACCOUNT_ID, currentUserEmail: CURRENT_USER_EMAIL, + policyTags: POLICY_TAGS, personalDetails: PERSONAL_DETAILS, }); // When we call filterAndOrderOptions with a search value that matches a personal detail @@ -2979,6 +3127,7 @@ describe('OptionsListUtils', () => { loginList, currentUserAccountID: CURRENT_USER_ACCOUNT_ID, currentUserEmail: CURRENT_USER_EMAIL, + policyTags: POLICY_TAGS, personalDetails: PERSONAL_DETAILS, }); // When we call filterAndOrderOptions with a search value that matches multiple items @@ -2995,12 +3144,14 @@ describe('OptionsListUtils', () => { .then(() => Onyx.set(ONYXKEYS.PERSONAL_DETAILS_LIST, PERSONAL_DETAILS_WITH_PERIODS)) .then(() => { // Given a set of options with periods - const OPTIONS_WITH_PERIODS = createOptionList(PERSONAL_DETAILS_WITH_PERIODS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS); + const OPTIONS_WITH_PERIODS = createOptionList(PERSONAL_DETAILS_WITH_PERIODS, undefined, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS); // When we call getSearchOptions const results = getSearchOptions({ options: OPTIONS_WITH_PERIODS, draftComments: {}, nvpDismissedProductTraining, + policyTags: POLICY_TAGS, + loginList, currentUserAccountID: CURRENT_USER_ACCOUNT_ID, currentUserEmail: CURRENT_USER_EMAIL, @@ -3039,6 +3190,8 @@ describe('OptionsListUtils', () => { reportAttributesDerived: MOCK_REPORT_ATTRIBUTES_DERIVED, draftComments: {}, nvpDismissedProductTraining, + policyTags: POLICY_TAGS, + loginList, betas: [CONST.BETAS.ALL], currentUserAccountID: CURRENT_USER_ACCOUNT_ID, @@ -3057,13 +3210,15 @@ describe('OptionsListUtils', () => { it('should order self dm always on top if the search matches with the self dm login', () => { const searchTerm = 'tonystark@expensify.com'; - const OPTIONS_WITH_SELF_DM = createOptionList(PERSONAL_DETAILS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS_WITH_SELF_DM); + const OPTIONS_WITH_SELF_DM = createOptionList(PERSONAL_DETAILS, undefined, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS_WITH_SELF_DM); // Given a set of options with self dm and all betas const options = getSearchOptions({ options: OPTIONS_WITH_SELF_DM, draftComments: {}, nvpDismissedProductTraining, + policyTags: POLICY_TAGS, + loginList, betas: [CONST.BETAS.ALL], currentUserAccountID: CURRENT_USER_ACCOUNT_ID, @@ -3118,7 +3273,7 @@ describe('OptionsListUtils', () => { renderLocaleContextProvider(); // Given a set of reports and personal details // When we call createOptionList and extract the reports - const reports = createOptionList(PERSONAL_DETAILS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS).reports; + const reports = createOptionList(PERSONAL_DETAILS, undefined, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS).reports; // Then the returned reports should match the expected values expect(reports.at(10)?.subtitle).toBe(`Submits to Mister Fantastic`); @@ -3129,7 +3284,7 @@ describe('OptionsListUtils', () => { .then(() => Onyx.set(ONYXKEYS.NVP_PREFERRED_LOCALE, CONST.LOCALES.ES)) .then(() => { // When we call createOptionList again - const newReports = createOptionList(PERSONAL_DETAILS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS).reports; + const newReports = createOptionList(PERSONAL_DETAILS, undefined, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS).reports; // Then the returned reports should change to Spanish // cspell:disable-next-line expect(newReports.at(10)?.subtitle).toBe('Se envía a Mister Fantastic'); @@ -3209,7 +3364,7 @@ describe('OptionsListUtils', () => { }, }); // When we call createOptionList - const reports = createOptionList(PERSONAL_DETAILS, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS).reports; + const reports = createOptionList(PERSONAL_DETAILS, undefined, CURRENT_USER_ACCOUNT_ID, EMPTY_PRIVATE_IS_ARCHIVED_MAP, REPORTS).reports; const archivedReport = reports.find((report) => report.reportID === '10'); // Then the returned report should contain default archived reason @@ -3225,7 +3380,7 @@ describe('OptionsListUtils', () => { }; // When we call createOptionList with this privateIsArchivedMap - const result = createOptionList(PERSONAL_DETAILS, CURRENT_USER_ACCOUNT_ID, privateIsArchivedMap, REPORTS); + const result = createOptionList(PERSONAL_DETAILS, undefined, CURRENT_USER_ACCOUNT_ID, privateIsArchivedMap, REPORTS); // Then the personal detail option for account 1 (Mister Fantastic) should have private_isArchived set const misterFantasticOption = result.personalDetails.find((pd) => pd.item?.accountID === 1); @@ -3238,7 +3393,7 @@ describe('OptionsListUtils', () => { const emptyMap: PrivateIsArchivedMap = {}; // When we call createOptionList with an empty privateIsArchivedMap - const result = createOptionList(PERSONAL_DETAILS, CURRENT_USER_ACCOUNT_ID, emptyMap, REPORTS); + const result = createOptionList(PERSONAL_DETAILS, undefined, CURRENT_USER_ACCOUNT_ID, emptyMap, REPORTS); // Then no personal details options should have private_isArchived set const optionsWithArchived = result.personalDetails.filter((pd) => pd.private_isArchived); @@ -3254,7 +3409,7 @@ describe('OptionsListUtils', () => { }; // When we call createOptionList with this privateIsArchivedMap - const result = createOptionList(PERSONAL_DETAILS, CURRENT_USER_ACCOUNT_ID, privateIsArchivedMap, REPORTS); + const result = createOptionList(PERSONAL_DETAILS, undefined, CURRENT_USER_ACCOUNT_ID, privateIsArchivedMap, REPORTS); // Then the personal detail options should have the correct private_isArchived values const misterFantasticOption = result.personalDetails.find((pd) => pd.item?.accountID === 1); @@ -3672,7 +3827,7 @@ describe('OptionsListUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`, transaction); await waitForBatchedUpdates(); - const result = createOption([1, 2], PERSONAL_DETAILS, report, CURRENT_USER_ACCOUNT_ID, {showChatPreviewLine: true}); + const result = createOption([1, 2], PERSONAL_DETAILS, report, CONST.POLICY.DEFAULT_TAG_LIST, CURRENT_USER_ACCOUNT_ID, {showChatPreviewLine: true}); expect(result.alternateText).toBe('Iron Man owes ₫34'); }); @@ -3734,6 +3889,7 @@ describe('OptionsListUtils', () => { report, lastActorDetails: null, isReportArchived: false, + policyTags: POLICY_TAGS, }); const reportPreviewMessage = getReportPreviewMessage(iouReport, iouAction, true, false, null, true, reportPreviewAction); const expected = formatReportLastMessageText(Parser.htmlToText(reportPreviewMessage)); @@ -3766,6 +3922,7 @@ describe('OptionsListUtils', () => { report, lastActorDetails: null, isReportArchived: false, + policyTags: POLICY_TAGS, }); expect(lastMessage).toBe(Parser.htmlToText(getMovedTransactionMessage(translateLocal, movedTransactionAction))); }); @@ -3789,6 +3946,7 @@ describe('OptionsListUtils', () => { report, lastActorDetails: null, isReportArchived: false, + policyTags: POLICY_TAGS, }); expect(lastMessage).toBe(Parser.htmlToText(translate(CONST.LOCALES.EN, 'iou.automaticallySubmitted'))); }); @@ -3813,6 +3971,7 @@ describe('OptionsListUtils', () => { report, lastActorDetails: null, isReportArchived: false, + policyTags: POLICY_TAGS, }); expect(lastMessage).toBe(Parser.htmlToText(translate(CONST.LOCALES.EN, 'iou.automaticallyApproved'))); }); @@ -3837,6 +3996,7 @@ describe('OptionsListUtils', () => { report, lastActorDetails: null, isReportArchived: false, + policyTags: POLICY_TAGS, }); expect(lastMessage).toBe(Parser.htmlToText(translate(CONST.LOCALES.EN, 'iou.automaticallyForwarded'))); }); @@ -3858,6 +4018,7 @@ describe('OptionsListUtils', () => { report, lastActorDetails: null, isReportArchived: false, + policyTags: POLICY_TAGS, }); expect(lastMessage).toBe(Parser.htmlToText(translate(CONST.LOCALES.EN, 'workspaceActions.forcedCorporateUpgrade'))); }); @@ -3878,6 +4039,7 @@ describe('OptionsListUtils', () => { report, lastActorDetails: null, isReportArchived: false, + policyTags: POLICY_TAGS, }); expect(lastMessage).toBe(Parser.htmlToText(getChangedApproverActionMessage(translateLocal, takeControlAction))); }); @@ -3897,6 +4059,7 @@ describe('OptionsListUtils', () => { report, lastActorDetails: null, isReportArchived: false, + policyTags: POLICY_TAGS, }); expect(lastMessage).toBe(Parser.htmlToText(getChangedApproverActionMessage(translateLocal, rerouteAction))); }); @@ -3916,6 +4079,7 @@ describe('OptionsListUtils', () => { report, lastActorDetails: null, isReportArchived: false, + policyTags: POLICY_TAGS, }); expect(lastMessage).toBe(Parser.htmlToText(getMovedActionMessage(translateLocal, movedAction, report))); }); @@ -3939,6 +4103,7 @@ describe('OptionsListUtils', () => { report, lastActorDetails: null, isReportArchived: false, + policyTags: POLICY_TAGS, }); // Then it should return the DYNAMIC_EXTERNAL_WORKFLOW_ROUTED message @@ -3964,6 +4129,7 @@ describe('OptionsListUtils', () => { report, lastActorDetails: null, isReportArchived: false, + policyTags: POLICY_TAGS, }); expect(result).toBe(expectedVisibleText); }); @@ -4014,6 +4180,7 @@ describe('OptionsListUtils', () => { isReportArchived: false, policy, reportMetadata, + policyTags: POLICY_TAGS, }); expect(lastMessage).toBe(translate(CONST.LOCALES.EN, 'iou.queuedToSubmitViaDEW')); }); @@ -4045,6 +4212,7 @@ describe('OptionsListUtils', () => { report, lastActorDetails: null, isReportArchived: false, + policyTags: POLICY_TAGS, }); expect(lastMessage).toBe(customErrorMessage); }); @@ -4073,6 +4241,7 @@ describe('OptionsListUtils', () => { report, lastActorDetails: null, isReportArchived: false, + policyTags: POLICY_TAGS, }); expect(lastMessage).toBe(translate(CONST.LOCALES.EN, 'iou.error.genericCreateFailureMessage')); }); @@ -4305,7 +4474,7 @@ describe('OptionsListUtils', () => { const personalDetails: PersonalDetailsList = PERSONAL_DETAILS; // When we call getReportDisplayOption - const result = getReportDisplayOption(report, undefined, CURRENT_USER_ACCOUNT_ID, personalDetails, undefined); + const result = getReportDisplayOption(report, undefined, undefined, CURRENT_USER_ACCOUNT_ID, personalDetails, undefined); // Then it should return an option with isSelfDM and alternateText set expect(result.isSelfDM).toBe(true); @@ -4325,7 +4494,7 @@ describe('OptionsListUtils', () => { const personalDetails: PersonalDetailsList = PERSONAL_DETAILS; // When we call getReportDisplayOption - const result = getReportDisplayOption(report, undefined, CURRENT_USER_ACCOUNT_ID, personalDetails, undefined); + const result = getReportDisplayOption(report, undefined, undefined, CURRENT_USER_ACCOUNT_ID, personalDetails, undefined); // Then it should return an option with invoice room text and alternateText expect(result.isInvoiceRoom).toBe(true); @@ -4347,7 +4516,7 @@ describe('OptionsListUtils', () => { const personalDetails: PersonalDetailsList = PERSONAL_DETAILS; // When we call getReportDisplayOption - const result = getReportDisplayOption(report, unknownUserDetails, CURRENT_USER_ACCOUNT_ID, personalDetails, undefined); + const result = getReportDisplayOption(report, unknownUserDetails, undefined, CURRENT_USER_ACCOUNT_ID, personalDetails, undefined); // Then it should return an option with unknownUserDetails data expect(result.text).toBe('Unknown User'); @@ -4368,7 +4537,7 @@ describe('OptionsListUtils', () => { const personalDetails: PersonalDetailsList = PERSONAL_DETAILS; // When we call getReportDisplayOption - const result = getReportDisplayOption(report, undefined, CURRENT_USER_ACCOUNT_ID, personalDetails, undefined); + const result = getReportDisplayOption(report, undefined, undefined, CURRENT_USER_ACCOUNT_ID, personalDetails, undefined); // Then it should return an option with workspace name expect(result.text).toBe(POLICY.name); @@ -4395,7 +4564,7 @@ describe('OptionsListUtils', () => { }; // When we call getReportDisplayOption with custom personalDetails - const result = getReportDisplayOption(report, undefined, CURRENT_USER_ACCOUNT_ID, customPersonalDetails, undefined); + const result = getReportDisplayOption(report, undefined, undefined, CURRENT_USER_ACCOUNT_ID, customPersonalDetails, undefined); // Then it should use the custom personalDetails parameter expect(result).toBeDefined(); @@ -4412,7 +4581,7 @@ describe('OptionsListUtils', () => { const emptyPersonalDetails: PersonalDetailsList = {}; // When we call getReportDisplayOption - const result = getReportDisplayOption(report, undefined, CURRENT_USER_ACCOUNT_ID, emptyPersonalDetails, undefined); + const result = getReportDisplayOption(report, undefined, undefined, CURRENT_USER_ACCOUNT_ID, emptyPersonalDetails, undefined); // Then it should not throw and return a valid option expect(result).toBeDefined(); @@ -4424,7 +4593,7 @@ describe('OptionsListUtils', () => { const personalDetails: PersonalDetailsList = PERSONAL_DETAILS; // When we call getReportDisplayOption with undefined report - const result = getReportDisplayOption(undefined, undefined, CURRENT_USER_ACCOUNT_ID, personalDetails, undefined); + const result = getReportDisplayOption(undefined, undefined, undefined, CURRENT_USER_ACCOUNT_ID, personalDetails, undefined); // Then it should return a valid option (createOption handles undefined) expect(result).toBeDefined(); @@ -4449,7 +4618,17 @@ 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, + undefined, + + loginList, + CURRENT_USER_ACCOUNT_ID, + CURRENT_USER_EMAIL, + ); expect(results).toBeDefined(); expect(results.recentReports).toBeDefined(); @@ -4458,7 +4637,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, undefined, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL); expect(results).toBeDefined(); expect(results.recentReports).toBeDefined(); @@ -4467,7 +4646,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, undefined, loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL); expect(results).toBeDefined(); expect(results.recentReports).toBeDefined(); @@ -4496,6 +4675,8 @@ describe('OptionsListUtils', () => { policies, undefined, nvpDismissedProductTraining, + undefined, + loginList, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, @@ -4549,7 +4730,7 @@ describe('OptionsListUtils', () => { isPolicyExpenseChat: true, }; - const option = getReportOption(participant, undefined, policy, CURRENT_USER_ACCOUNT_ID, {}); + const option = getReportOption(participant, undefined, undefined, policy, CURRENT_USER_ACCOUNT_ID, {}); expect(option.text).toBe('Test Workspace'); expect(option.alternateText).toBe(translateLocal('workspace.common.workspace')); @@ -4604,7 +4785,7 @@ describe('OptionsListUtils', () => { isPolicyExpenseChat: true, }; - const option = getReportOption(participant, undefined, policy, CURRENT_USER_ACCOUNT_ID, {}); + const option = getReportOption(participant, undefined, undefined, policy, CURRENT_USER_ACCOUNT_ID, {}); expect(option.text).toBe('Test Workspace with Submit'); // The submitsTo logic may or may not apply depending on complex approval rules @@ -4627,7 +4808,7 @@ describe('OptionsListUtils', () => { reportID, }; - const option = getReportOption(participant, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, {}); + const option = getReportOption(participant, undefined, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, {}); expect(option.isDisabled).toBe(true); }); @@ -4663,7 +4844,7 @@ describe('OptionsListUtils', () => { isSelfDM: true, }; - const option = getReportOption(participant, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, personalDetails); + const option = getReportOption(participant, undefined, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, personalDetails); // The option.isSelfDM is set by createOption based on the report type // Just verify the alternateText is correct for self DM @@ -4698,7 +4879,7 @@ describe('OptionsListUtils', () => { isInvoiceRoom: true, }; - const option = getReportOption(participant, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, {}); + const option = getReportOption(participant, undefined, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, {}); expect(option.isInvoiceRoom).toBe(true); expect(option.alternateText).toBe(translateLocal('workspace.common.invoices')); @@ -4739,7 +4920,7 @@ describe('OptionsListUtils', () => { }); await waitForBatchedUpdates(); - const option = getReportOption(participant, reportNameValuePair?.private_isArchived, POLICY, CURRENT_USER_ACCOUNT_ID, {}); + const option = getReportOption(participant, undefined, reportNameValuePair?.private_isArchived, POLICY, CURRENT_USER_ACCOUNT_ID, {}); expect(option.text).toBe(POLICY.name); expect(option.alternateText).toBeTruthy(); @@ -4783,7 +4964,7 @@ describe('OptionsListUtils', () => { }); await waitForBatchedUpdates(); - const option = getReportOption(participant, reportNameValuePair?.private_isArchived, POLICY, CURRENT_USER_ACCOUNT_ID, {}, undefined, draftReports); + const option = getReportOption(participant, undefined, reportNameValuePair?.private_isArchived, POLICY, CURRENT_USER_ACCOUNT_ID, {}, undefined, draftReports); expect(option.isDisabled).toBe(true); }); @@ -4805,7 +4986,7 @@ describe('OptionsListUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, report); await waitForBatchedUpdates(); - const option = getReportDisplayOption(report, undefined, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS, reportNameValuePair?.private_isArchived); + const option = getReportDisplayOption(report, undefined, undefined, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS, reportNameValuePair?.private_isArchived); expect(option).toBeDefined(); expect(option.reportID).toBe(reportID); @@ -4828,7 +5009,7 @@ describe('OptionsListUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, report); await waitForBatchedUpdates(); - const option = getReportDisplayOption(report, undefined, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS, reportNameValuePair?.private_isArchived); + const option = getReportDisplayOption(report, undefined, undefined, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS, reportNameValuePair?.private_isArchived); expect(option).toBeDefined(); expect(option.reportID).toBe(reportID); @@ -4848,7 +5029,7 @@ describe('OptionsListUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, report); await waitForBatchedUpdates(); - const option = getReportDisplayOption(report, undefined, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS, undefined); + const option = getReportDisplayOption(report, undefined, undefined, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS, undefined); expect(option).toBeDefined(); expect(option.reportID).toBe(reportID); @@ -4872,7 +5053,7 @@ describe('OptionsListUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, report); await waitForBatchedUpdates(); - const option = getReportDisplayOption(report, undefined, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS, reportNameValuePair?.private_isArchived); + const option = getReportDisplayOption(report, undefined, undefined, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS, reportNameValuePair?.private_isArchived); expect(option).toBeDefined(); expect(option.reportID).toBe(reportID); @@ -4896,7 +5077,7 @@ describe('OptionsListUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, report); await waitForBatchedUpdates(); - const option = getReportDisplayOption(report, undefined, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS, reportNameValuePair?.private_isArchived); + const option = getReportDisplayOption(report, undefined, undefined, CURRENT_USER_ACCOUNT_ID, PERSONAL_DETAILS, reportNameValuePair?.private_isArchived); expect(option).toBeDefined(); expect(option.reportID).toBe(reportID); @@ -4919,7 +5100,7 @@ describe('OptionsListUtils', () => { selected: true, }; - const option = getReportOption(participant, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, {}); + const option = getReportOption(participant, undefined, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, {}); expect(option.isSelected).toBe(true); expect(option.selected).toBe(true); @@ -4940,7 +5121,7 @@ describe('OptionsListUtils', () => { reportID, }; - const option = getReportOption(participant, undefined, undefined, CURRENT_USER_ACCOUNT_ID, {}); + const option = getReportOption(participant, undefined, undefined, undefined, CURRENT_USER_ACCOUNT_ID, {}); expect(option).toBeDefined(); expect(option.text).toBeDefined(); @@ -4962,7 +5143,7 @@ describe('OptionsListUtils', () => { }; // Test that the function works with reportAttributesDerived parameter (optional) - const option = getReportOption(participant, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, {}); + const option = getReportOption(participant, undefined, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, {}); expect(option).toBeDefined(); }); @@ -4996,7 +5177,7 @@ describe('OptionsListUtils', () => { reportID, }; - const option = getReportOption(participant, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, testPersonalDetails); + const option = getReportOption(participant, undefined, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, testPersonalDetails); expect(option).toBeDefined(); // The createOption function uses personalDetails to build display names @@ -5057,7 +5238,7 @@ describe('OptionsListUtils', () => { isPolicyExpenseChat: true, }; - const option = getReportOption(participant, undefined, policy, CURRENT_USER_ACCOUNT_ID, testPersonalDetails); + const option = getReportOption(participant, undefined, undefined, policy, CURRENT_USER_ACCOUNT_ID, testPersonalDetails); expect(option).toBeDefined(); expect(option.text).toBe('Test Workspace with Approver'); @@ -5082,7 +5263,7 @@ describe('OptionsListUtils', () => { }; // Pass empty personalDetails - const option = getReportOption(participant, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, {}); + const option = getReportOption(participant, undefined, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, {}); expect(option).toBeDefined(); expect(option.text).toBeDefined(); @@ -5104,7 +5285,7 @@ describe('OptionsListUtils', () => { }; // Pass undefined personalDetails - const option = getReportOption(participant, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, undefined); + const option = getReportOption(participant, undefined, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, undefined); expect(option).toBeDefined(); expect(option.text).toBeDefined(); @@ -5150,7 +5331,7 @@ describe('OptionsListUtils', () => { isInvoiceRoom: true, }; - const option = getReportOption(participant, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, testPersonalDetails); + const option = getReportOption(participant, undefined, undefined, POLICY, CURRENT_USER_ACCOUNT_ID, testPersonalDetails); expect(option).toBeDefined(); expect(option.isInvoiceRoom).toBe(true); @@ -5207,7 +5388,7 @@ describe('OptionsListUtils', () => { selected: true, }; - const option = getPolicyExpenseReportOption(participant, CURRENT_USER_ACCOUNT_ID, testPersonalDetails); + const option = getPolicyExpenseReportOption(participant, undefined, CURRENT_USER_ACCOUNT_ID, testPersonalDetails); expect(option).toBeDefined(); expect(option.text).toBe('Test Workspace Policy'); @@ -5268,7 +5449,7 @@ describe('OptionsListUtils', () => { isPolicyExpenseChat: true, }; - const option = getPolicyExpenseReportOption(participant, CURRENT_USER_ACCOUNT_ID, testPersonalDetails); + const option = getPolicyExpenseReportOption(participant, undefined, CURRENT_USER_ACCOUNT_ID, testPersonalDetails); expect(option).toBeDefined(); expect(option.text).toBe('Team Workspace'); @@ -5312,7 +5493,7 @@ describe('OptionsListUtils', () => { }; // Should not throw when personalDetails is empty - const option = getPolicyExpenseReportOption(participant, CURRENT_USER_ACCOUNT_ID, {}); + const option = getPolicyExpenseReportOption(participant, undefined, CURRENT_USER_ACCOUNT_ID, {}); expect(option).toBeDefined(); expect(option.text).toBe('Workspace Without Details'); @@ -5356,7 +5537,7 @@ describe('OptionsListUtils', () => { }; // Should not throw when personalDetails is undefined - const option = getPolicyExpenseReportOption(participant, CURRENT_USER_ACCOUNT_ID, undefined); + const option = getPolicyExpenseReportOption(participant, undefined, CURRENT_USER_ACCOUNT_ID, undefined); expect(option).toBeDefined(); expect(option.text).toBe('Workspace Undefined Details'); @@ -5408,10 +5589,10 @@ describe('OptionsListUtils', () => { selected: false, }; - const optionSelected = getPolicyExpenseReportOption(participantSelected, CURRENT_USER_ACCOUNT_ID, {}); + const optionSelected = getPolicyExpenseReportOption(participantSelected, undefined, CURRENT_USER_ACCOUNT_ID, {}); // eslint-disable-next-line rulesdir/no-negated-variables - const optionNotSelected = getPolicyExpenseReportOption(participantNotSelected, CURRENT_USER_ACCOUNT_ID, {}); + const optionNotSelected = getPolicyExpenseReportOption(participantNotSelected, undefined, CURRENT_USER_ACCOUNT_ID, {}); expect(optionSelected.isSelected).toBe(true); expect(optionSelected.selected).toBe(true); diff --git a/tests/unit/SidebarUtilsTest.ts b/tests/unit/SidebarUtilsTest.ts index 8c95f687dd495..c74fb7fdcb4e6 100644 --- a/tests/unit/SidebarUtilsTest.ts +++ b/tests/unit/SidebarUtilsTest.ts @@ -352,6 +352,7 @@ describe('SidebarUtils', () => { lastAction: undefined, lastActionReport: undefined, isReportArchived: undefined, + policyTags: undefined, currentUserAccountID: 0, reportAttributesDerived: undefined, }); @@ -369,6 +370,7 @@ describe('SidebarUtils', () => { lastAction: undefined, lastActionReport: undefined, isReportArchived: undefined, + policyTags: undefined, currentUserAccountID: 0, reportAttributesDerived: undefined, }); @@ -1172,6 +1174,7 @@ describe('SidebarUtils', () => { lastAction, lastActionReport: undefined, isReportArchived: undefined, + policyTags: undefined, currentUserAccountID: 0, reportAttributesDerived: undefined, }); @@ -1235,6 +1238,7 @@ describe('SidebarUtils', () => { lastAction, lastActionReport: undefined, isReportArchived: undefined, + policyTags: undefined, currentUserAccountID: 0, reportAttributesDerived: undefined, }); @@ -1301,6 +1305,7 @@ describe('SidebarUtils', () => { lastAction, lastActionReport: undefined, isReportArchived: undefined, + policyTags: undefined, currentUserAccountID: 0, reportAttributesDerived: undefined, }); @@ -1352,6 +1357,7 @@ describe('SidebarUtils', () => { localeCompare, lastActionReport: undefined, isReportArchived: undefined, + policyTags: undefined, currentUserAccountID: 0, }); @@ -1393,6 +1399,7 @@ describe('SidebarUtils', () => { localeCompare, isReportArchived: true, lastActionReport: undefined, + policyTags: undefined, currentUserAccountID: 0, reportAttributesDerived: undefined, }); @@ -1432,6 +1439,7 @@ describe('SidebarUtils', () => { localeCompare, lastActionReport: undefined, isReportArchived: undefined, + policyTags: undefined, currentUserAccountID: 0, }); @@ -1569,6 +1577,7 @@ describe('SidebarUtils', () => { localeCompare, lastActionReport: undefined, isReportArchived: undefined, + policyTags: undefined, currentUserAccountID: 0, reportAttributesDerived: mockReportAttributesDerived, }); @@ -1613,6 +1622,7 @@ describe('SidebarUtils', () => { localeCompare, lastActionReport: undefined, isReportArchived: undefined, + policyTags: undefined, currentUserAccountID: 0, }); @@ -1685,6 +1695,7 @@ describe('SidebarUtils', () => { lastAction, lastActionReport: undefined, isReportArchived: undefined, + policyTags: undefined, currentUserAccountID: session.accountID, }); @@ -1746,6 +1757,7 @@ describe('SidebarUtils', () => { lastAction, lastActionReport: undefined, isReportArchived: undefined, + policyTags: undefined, currentUserAccountID: session.accountID, }); @@ -1798,6 +1810,7 @@ describe('SidebarUtils', () => { lastActionReport: undefined, isReportArchived: undefined, lastMessageTextFromReport: report.lastMessageText, + policyTags: undefined, currentUserAccountID: session.accountID, }); @@ -1875,12 +1888,11 @@ describe('SidebarUtils', () => { lastAction, lastActionReport: undefined, isReportArchived: undefined, + policyTags: undefined, currentUserAccountID: session.accountID, }); - expect(result?.alternateText).toBe(`You: ${getReportActionMessageText(lastAction)}`); }); - it('uses the 2nd-last visible message as alternateText when the latest action is a deleted IOU', async () => { const MOCK_REPORT: Report = { reportID: '1', @@ -1994,6 +2006,7 @@ describe('SidebarUtils', () => { lastAction, lastActionReport: undefined, isReportArchived: undefined, + policyTags: undefined, currentUserAccountID: 0, }); @@ -2080,6 +2093,7 @@ describe('SidebarUtils', () => { lastAction, lastActionReport: undefined, isReportArchived: undefined, + policyTags: undefined, currentUserAccountID: 0, }); @@ -2178,6 +2192,7 @@ describe('SidebarUtils', () => { localeCompare, lastActionReport: undefined, isReportArchived: undefined, + policyTags: undefined, currentUserAccountID: managerID, }); @@ -2277,6 +2292,7 @@ describe('SidebarUtils', () => { localeCompare, lastActionReport: undefined, isReportArchived: undefined, + policyTags: undefined, currentUserAccountID: managerID, });