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/Duplicate.ts b/src/libs/actions/IOU/Duplicate.ts index e0a8909d8ed3..16ec5d43afc5 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'; @@ -654,7 +652,6 @@ function createExpenseByType({ personalDetails, recentWaypoints, isTrackIntentUser, - policyTagList, }: { transactionType: string; params: RequestMoneyInformation; @@ -668,7 +665,6 @@ function createExpenseByType({ personalDetails: OnyxEntry; recentWaypoints: OnyxEntry; isTrackIntentUser: boolean | undefined; - policyTagList: OnyxTypes.PolicyTagLists; }) { switch (transactionType) { case CONST.SEARCH.TRANSACTION_TYPE.DISTANCE: { @@ -677,7 +673,6 @@ function createExpenseByType({ participants, currentUserLogin: params.currentUserEmailParam, currentUserAccountID: params.currentUserAccountIDParam, - policyParams: {...params.policyParams, policyTagList}, existingTransaction: { iouRequestType: getDuplicateRequestType(transaction), amount: 0, @@ -726,7 +721,6 @@ function createExpenseByType({ default: return requestMoney({ ...params, - policyParams: {...(params.policyParams ?? {}), policyTagList}, }); } } @@ -777,7 +771,6 @@ function duplicateExpenseTransaction({ betas, personalDetails, recentWaypoints, - targetPolicyTags, shouldPlaySound = true, shouldDeferAutoSubmit = false, existingIOUReport, @@ -883,7 +876,7 @@ function duplicateExpenseTransaction({ params.policyParams = { policy: targetPolicy, - policyTagList: targetPolicyTags, + policyTagList, policyCategories: targetPolicyCategories ?? {}, }; @@ -900,7 +893,6 @@ function duplicateExpenseTransaction({ personalDetails, recentWaypoints, isTrackIntentUser, - policyTagList, }); } @@ -1056,18 +1048,6 @@ function duplicateReport({ delegateAccountID, }; - 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, @@ -1081,7 +1061,6 @@ function duplicateReport({ personalDetails, recentWaypoints, isTrackIntentUser, - policyTagList, }); if (result?.iouReport) { 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, };