diff --git a/ios/Podfile.lock b/ios/Podfile.lock index d0007ec51668..6c67fecc7ffc 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1917,4 +1917,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: a431c146e1501391834a2f299a74093bac53b530 -COCOAPODS: 1.13.0 +COCOAPODS: 1.12.1 diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 8dc1c9967f13..8f8785d36fd3 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2345,6 +2345,31 @@ function hasMissingSmartscanFields(iouReportID: string): boolean { return TransactionUtils.getAllReportTransactions(iouReportID).some((transaction) => TransactionUtils.hasMissingSmartscanFields(transaction)); } +/** + * Get the transactions related to a report preview with receipts + * Get the details linked to the IOU reportAction + * + * NOTE: This method is only meant to be used inside this action file. Do not export and use it elsewhere. Use withOnyx or Onyx.connect() instead. + */ +function getLinkedTransaction(reportAction: OnyxEntry): Transaction | EmptyObject { + let transactionID = ''; + + if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU) { + transactionID = (reportAction?.originalMessage as IOUMessage)?.IOUTransactionID ?? ''; + } + + return allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`] ?? {}; +} + +/** + * Retrieve the particular transaction object given its ID. + * + * NOTE: This method is only meant to be used inside this action file. Do not export and use it elsewhere. Use withOnyx or Onyx.connect() instead. + */ +function getTransaction(transactionID: string): OnyxEntry | EmptyObject { + return allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`] ?? {}; +} + /** * Given a parent IOU report action get report name for the LHN. */ @@ -2357,7 +2382,7 @@ function getTransactionReportName(reportAction: OnyxEntry) return Localize.translateLocal(translationKey, {amount: formattedAmount, payer: ''}); } - const transaction = TransactionUtils.getTransaction(originalMessage.IOUTransactionID ?? ''); + const transaction = getTransaction(originalMessage.IOUTransactionID ?? ''); const transactionDetails = getTransactionDetails(!isEmptyObject(transaction) ? transaction : null); const formattedAmount = CurrencyUtils.convertToDisplayString(transactionDetails?.amount ?? 0, transactionDetails?.currency); const isRequestSettled = isSettled(originalMessage.IOUReportID); diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts index f8f9ed0e0d47..bc94c8fee8fc 100644 --- a/src/libs/TransactionUtils.ts +++ b/src/libs/TransactionUtils.ts @@ -4,16 +4,13 @@ import Onyx from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {RecentWaypoint, Report, ReportAction, TaxRate, TaxRates, Transaction, TransactionViolation} from '@src/types/onyx'; -import type {IOUMessage} from '@src/types/onyx/OriginalMessage'; +import type {RecentWaypoint, Report, TaxRate, TaxRates, Transaction, TransactionViolation} from '@src/types/onyx'; import type {Comment, Receipt, TransactionChanges, TransactionPendingFieldsKey, Waypoint, WaypointCollection} from '@src/types/onyx/Transaction'; -import type {EmptyObject} from '@src/types/utils/EmptyObject'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import {isCorporateCard, isExpensifyCard} from './CardUtils'; import DateUtils from './DateUtils'; import * as NumberUtils from './NumberUtils'; import {getCleanedTagName} from './PolicyUtils'; -import type {OptimisticIOUReportAction} from './ReportUtils'; let allTransactions: OnyxCollection = {}; @@ -248,15 +245,6 @@ function getUpdatedTransaction(transaction: Transaction, transactionChanges: Tra return updatedTransaction; } -/** - * Retrieve the particular transaction object given its ID. - * - * @deprecated Use withOnyx() or Onyx.connect() instead - */ -function getTransaction(transactionID: string): OnyxEntry | EmptyObject { - return allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`] ?? {}; -} - /** * Return the comment field (referred to as description in the App) from the transaction. * The comment does not have its modifiedComment counterpart. @@ -493,22 +481,6 @@ function hasRoute(transaction: OnyxEntry): boolean { return !!transaction?.routes?.route0?.geometry?.coordinates; } -/** - * Get the transactions related to a report preview with receipts - * Get the details linked to the IOU reportAction - * - * @deprecated Use Onyx.connect() or withOnyx() instead - */ -function getLinkedTransaction(reportAction: OnyxEntry): Transaction | EmptyObject { - let transactionID = ''; - - if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU) { - transactionID = (reportAction?.originalMessage as IOUMessage)?.IOUTransactionID ?? ''; - } - - return allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`] ?? {}; -} - function getAllReportTransactions(reportID?: string): Transaction[] { // `reportID` from the `/CreateDistanceRequest` endpoint return's number instead of string for created `transaction`. // For reference, https://github.com/Expensify/App/pull/26536#issuecomment-1703573277. @@ -617,7 +589,6 @@ export { calculateTaxAmount, getEnabledTaxRateCount, getUpdatedTransaction, - getTransaction, getDescription, getHeaderTitleTranslationKey, getRequestType, @@ -638,7 +609,6 @@ export { getTagArrayFromName, getTagForDisplay, getTransactionViolations, - getLinkedTransaction, getAllReportTransactions, hasReceipt, hasEReceipt,