Skip to content

Commit e7132ec

Browse files
authored
Merge pull request Expensify#65769 from Expensify/Rory-AddBackDeletedMethod
[No QA] Add back deleted function
2 parents aefefde + 081eb74 commit e7132ec

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/libs/MoneyRequestReportUtils.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,24 @@ const getTotalAmountForIOUReportPreviewButton = (report: OnyxEntry<Report>, poli
154154
return convertToDisplayString(totalDisplaySpend, report?.currency);
155155
};
156156

157+
/**
158+
* Filters all available transactions and returns the ones that belong to a specific report (by `reportID`).
159+
* It is used as an onyx selector, to make sure that report related views do not process all transactions in onyx.
160+
*/
161+
function selectAllTransactionsForReport(transactions: OnyxCollection<Transaction>, reportID: string | undefined, reportActions: ReportAction[]) {
162+
if (!reportID) {
163+
return [];
164+
}
165+
166+
return Object.values(transactions ?? {}).filter((transaction): transaction is Transaction => {
167+
if (!transaction) {
168+
return false;
169+
}
170+
const action = getIOUActionForTransactionID(reportActions, transaction.transactionID);
171+
return transaction.reportID === reportID && !isDeletedParentAction(action);
172+
});
173+
}
174+
157175
export {
158176
isActionVisibleOnMoneyRequestReport,
159177
getThreadReportIDsForTransactions,
@@ -163,4 +181,5 @@ export {
163181
isSingleTransactionReport,
164182
shouldDisplayReportTableView,
165183
shouldWaitForTransactions,
184+
selectAllTransactionsForReport,
166185
};

0 commit comments

Comments
 (0)