Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/libs/MoneyRequestReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,24 @@ const getTotalAmountForIOUReportPreviewButton = (report: OnyxEntry<Report>, 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<Transaction>, 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,
Expand All @@ -163,4 +181,5 @@ export {
isSingleTransactionReport,
shouldDisplayReportTableView,
shouldWaitForTransactions,
selectAllTransactionsForReport,
};
Loading