Skip to content

Commit

Permalink
Merge pull request Expensify#46006 from callstack-internal/fix/optimi…
Browse files Browse the repository at this point in the history
…ze-getAllReportTransactions

perf: optimize getAllReportTransactions
  • Loading branch information
mountiny authored Jul 23, 2024
2 parents 8a8bdf6 + a35c30f commit 17a8bbd
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/libs/TransactionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,11 +579,10 @@ function hasRoute(transaction: OnyxEntry<Transaction>, isDistanceRequestType?: b
}

function getAllReportTransactions(reportID?: string, transactions?: OnyxCollection<Transaction>): 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.
// We will update this in a follow-up Issue. According to this comment: https://github.com/Expensify/App/pull/26536#issuecomment-1703591019.
const nonNullableTransactions: Transaction[] = Object.values(transactions ?? allTransactions ?? {}).filter((transaction): transaction is Transaction => !!transaction);
return nonNullableTransactions.filter((transaction) => `${transaction.reportID}` === `${reportID}`);
const reportTransactions: Transaction[] = Object.values(transactions ?? allTransactions ?? {}).filter(
(transaction): transaction is Transaction => !!transaction && transaction.reportID === reportID,
);
return reportTransactions;
}

function waypointHasValidAddress(waypoint: RecentWaypoint | Waypoint): boolean {
Expand Down

0 comments on commit 17a8bbd

Please sign in to comment.