From 081eb740d1479a07316463ed49f0126ed2e60b2e Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 9 Jul 2025 12:47:17 -0400 Subject: [PATCH] Add back eleted function --- src/libs/MoneyRequestReportUtils.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/libs/MoneyRequestReportUtils.ts b/src/libs/MoneyRequestReportUtils.ts index 625512b315185..8e637da4959d4 100644 --- a/src/libs/MoneyRequestReportUtils.ts +++ b/src/libs/MoneyRequestReportUtils.ts @@ -154,6 +154,24 @@ const getTotalAmountForIOUReportPreviewButton = (report: OnyxEntry, poli return convertToDisplayString(totalDisplaySpend, report?.currency); }; +/** + * Filters all available transactions and returns the ones that belong to a specific report (by `reportID`). + * It is used as an onyx selector, to make sure that report related views do not process all transactions in onyx. + */ +function selectAllTransactionsForReport(transactions: OnyxCollection, reportID: string | undefined, reportActions: ReportAction[]) { + if (!reportID) { + return []; + } + + return Object.values(transactions ?? {}).filter((transaction): transaction is Transaction => { + if (!transaction) { + return false; + } + const action = getIOUActionForTransactionID(reportActions, transaction.transactionID); + return transaction.reportID === reportID && !isDeletedParentAction(action); + }); +} + export { isActionVisibleOnMoneyRequestReport, getThreadReportIDsForTransactions, @@ -163,4 +181,5 @@ export { isSingleTransactionReport, shouldDisplayReportTableView, shouldWaitForTransactions, + selectAllTransactionsForReport, };