From 53dbc0a8f1ae70c25da969ea74a210ad96d021f1 Mon Sep 17 00:00:00 2001 From: Wiktor Gut Date: Thu, 9 Jul 2026 19:09:45 +0200 Subject: [PATCH 1/3] Remove Onyx.connect() usage for ONYXKEYS.COLLECTION.POLICY_TAGS from duplicateReport Drop the deprecated getMoneyRequestPolicyTags computation from Duplicate.ts and rely on the policy tags passed down reactively: - duplicateReport now uses the targetPolicyTags param (resolved in bulkDuplicateReports from the useOnyx-provided allPolicyTags) instead of computing them via the deprecated getMoneyRequestPolicyTags - createExpenseByType no longer takes a policyTagList override; it uses params.policyParams - duplicateExpenseTransaction sets policyParams.policyTagList from its policyTagList param - removed now-unused imports (getMoneyRequestPolicyTags, getReportOrDraftReport, isMoneyRequestReport) Part of the Onyx.connect migration (https://github.com/Expensify/App/issues/72721). --- src/libs/actions/IOU/Duplicate.ts | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/src/libs/actions/IOU/Duplicate.ts b/src/libs/actions/IOU/Duplicate.ts index e879e2d453ac..14a09cc4405b 100644 --- a/src/libs/actions/IOU/Duplicate.ts +++ b/src/libs/actions/IOU/Duplicate.ts @@ -20,9 +20,7 @@ import { canAddTransaction, generateReportID, getReimbursableTotal, - getReportOrDraftReport, getTransactionDetails, - isMoneyRequestReport as isMoneyRequestReportReportUtils, } from '@libs/ReportUtils'; import playSound, {SOUNDS} from '@libs/Sound'; import { @@ -61,7 +59,7 @@ import type {PerDiemExpenseInformation} from './PerDiem'; import type {CreateDistanceRequestInformation} from './Split'; import type {CreateTrackExpenseParams} from './TrackExpense'; -import {getAllReportActionsFromIOU, getAllReports, getAllTransactions, getMoneyRequestPolicyTags} from '.'; +import {getAllReportActionsFromIOU, getAllReports, getAllTransactions} from '.'; import {getCleanUpTransactionThreadReportOnyxData} from './DeleteMoneyRequest'; import {getMoneyRequestParticipantsFromReport} from './MoneyRequest'; import {submitPerDiemExpense} from './PerDiem'; @@ -653,7 +651,6 @@ function createExpenseByType({ customUnitPolicyID, personalDetails, recentWaypoints, - policyTagList, }: { transactionType: string; params: RequestMoneyInformation; @@ -666,7 +663,6 @@ function createExpenseByType({ customUnitPolicyID?: string; personalDetails: OnyxEntry; recentWaypoints: OnyxEntry; - policyTagList: OnyxTypes.PolicyTagLists; }) { switch (transactionType) { case CONST.SEARCH.TRANSACTION_TYPE.DISTANCE: { @@ -675,7 +671,7 @@ function createExpenseByType({ participants, currentUserLogin: params.currentUserEmailParam, currentUserAccountID: params.currentUserAccountIDParam, - policyParams: {...params.policyParams, policyTagList}, + policyParams: params.policyParams, existingTransaction: { iouRequestType: getDuplicateRequestType(transaction), amount: 0, @@ -723,7 +719,7 @@ function createExpenseByType({ default: return requestMoney({ ...params, - policyParams: {...(params.policyParams ?? {}), policyTagList}, + policyParams: params.policyParams, }); } } @@ -772,7 +768,6 @@ function duplicateExpenseTransaction({ betas, personalDetails, recentWaypoints, - targetPolicyTags, shouldPlaySound = true, shouldDeferAutoSubmit = false, existingIOUReport, @@ -873,7 +868,7 @@ function duplicateExpenseTransaction({ params.policyParams = { policy: targetPolicy, - policyTagList: targetPolicyTags, + policyTagList, policyCategories: targetPolicyCategories ?? {}, }; @@ -889,7 +884,6 @@ function duplicateExpenseTransaction({ customUnitPolicyID, personalDetails, recentWaypoints, - policyTagList, }); } @@ -1029,18 +1023,6 @@ function duplicateReport({ shouldDeferAutoSubmit: !isLastExpense, }; - const isMoneyRequestReport = isMoneyRequestReportReportUtils(params.report); - const currentChatReport = isMoneyRequestReport ? getReportOrDraftReport(params.report?.chatReportID) : params.report; - const moneyRequestReportID = isMoneyRequestReport ? params.report?.reportID : ''; - // Part of the onyx.connect migration, it will be removed in further PRs (https://github.com/Expensify/App/issues/72721). - // eslint-disable-next-line @typescript-eslint/no-deprecated - const policyTagList = getMoneyRequestPolicyTags({ - existingIOUReport: params.existingIOUReport, - moneyRequestReportID, - parentChatReport: currentChatReport, - participant: participants.at(0) ?? {}, - }); - const result = createExpenseByType({ transactionType: getTransactionType(transaction), params, @@ -1053,7 +1035,6 @@ function duplicateReport({ customUnitPolicyID: targetPolicy?.id, personalDetails, recentWaypoints, - policyTagList, }); if (result?.iouReport) { From 49018b25b8c6e5f6debb5273a948551c0d8affcc Mon Sep 17 00:00:00 2001 From: Wiktor Gut Date: Thu, 9 Jul 2026 19:27:50 +0200 Subject: [PATCH 2/3] Remove redundant policyParams override in createExpenseByType The spread of `...params` already carries `params.policyParams` (which includes the policyTagList set by the callers), so the explicit `policyParams: params.policyParams` in the DISTANCE and default branches was redundant. --- src/libs/actions/IOU/Duplicate.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/actions/IOU/Duplicate.ts b/src/libs/actions/IOU/Duplicate.ts index 14a09cc4405b..eb27134cb6a2 100644 --- a/src/libs/actions/IOU/Duplicate.ts +++ b/src/libs/actions/IOU/Duplicate.ts @@ -671,7 +671,6 @@ function createExpenseByType({ participants, currentUserLogin: params.currentUserEmailParam, currentUserAccountID: params.currentUserAccountIDParam, - policyParams: params.policyParams, existingTransaction: { iouRequestType: getDuplicateRequestType(transaction), amount: 0, @@ -719,7 +718,6 @@ function createExpenseByType({ default: return requestMoney({ ...params, - policyParams: params.policyParams, }); } } From 3afe07104b6ee46618f49a82e87dab1578db1603 Mon Sep 17 00:00:00 2001 From: Wiktor Gut Date: Tue, 14 Jul 2026 00:38:53 +0200 Subject: [PATCH 3/3] remove getMoneyRequestPolicyTags --- src/hooks/useMoneyRequestPolicyTags.ts | 3 +-- src/libs/actions/IOU/index.ts | 25 ------------------------- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/src/hooks/useMoneyRequestPolicyTags.ts b/src/hooks/useMoneyRequestPolicyTags.ts index db7b002949e5..ebb42b8c9ea0 100644 --- a/src/hooks/useMoneyRequestPolicyTags.ts +++ b/src/hooks/useMoneyRequestPolicyTags.ts @@ -18,8 +18,7 @@ type UseMoneyRequestPolicyTagsParams = { const selectReportPolicyID = (report: OnyxEntry) => report?.policyID; /** - * Resolves the `PolicyTagLists` for the money-request flow — a reactive replacement for the deprecated - * `getMoneyRequestPolicyTags`, picking the policy from the IOU/money-request/chat/participant reports in order. + * Resolves the `PolicyTagLists` for the money-request flow, picking the policy from the IOU/money-request/chat/participant reports in order. * * Case-specific: it mirrors how these flows resolve their policy, not a general-purpose hook. */ diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index 72440db5c314..b79024bab82d 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -194,30 +194,6 @@ function getPolicyTagsData(policyID: string | undefined) { return allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`] ?? {}; } -/** - * @deprecated This function uses Onyx.connect and should be replaced with useOnyx for reactive data access. - * TODO: remove `getMoneyRequestPolicyTags` from this file (https://github.com/Expensify/App/issues/72721) - * All usages of this function should be replaced with useOnyx hook in React components. - */ -function getMoneyRequestPolicyTags({ - existingIOUReport, - moneyRequestReportID, - parentChatReport, - participant, -}: { - existingIOUReport?: OnyxEntry; - moneyRequestReportID?: string; - parentChatReport: OnyxEntry; - participant: Participant; -}): OnyxTypes.PolicyTagLists { - const iouReportPolicyID = - existingIOUReport?.policyID ?? - (moneyRequestReportID ? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${moneyRequestReportID}`]?.policyID : undefined) ?? - parentChatReport?.policyID ?? - allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${participant.reportID}`]?.policyID; - return getPolicyTagsData(iouReportPolicyID) ?? {}; -} - export { getAllPersonalDetails, getAllTransactions, @@ -234,5 +210,4 @@ export { // TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) and getPolicyRecentlyUsedTagsData (https://github.com/Expensify/App/issues/71491) with useOnyx hook getPolicyTagsData, getPolicyTags, - getMoneyRequestPolicyTags, };