Skip to content

Commit

Permalink
Merge pull request #56089 from Expensify/cristi_fix-useTrpTransaction…
Browse files Browse the repository at this point in the history
…s-hook

[No QA] Fix useTripTransactions hook
  • Loading branch information
cristipaval authored Jan 30, 2025
2 parents 9f6794a + 40b59bc commit 4cf24c5
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/hooks/useTripTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ function useTripTransactions(reportID: string | undefined): Transaction[] {
.filter((report) => report && report.chatReportID === reportID)
.map((report) => report?.reportID),
});
const [tripTransactions = []] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {
selector: (transactions) => {
if (!tripTransactionReportIDs.length) {
return [];
}
const [tripTransactions = []] = useOnyx(
ONYXKEYS.COLLECTION.TRANSACTION,
{
selector: (transactions) => {
if (!tripTransactionReportIDs.length) {
return [];
}

return Object.values(transactions ?? {}).filter((transaction): transaction is Transaction => !!transaction && tripTransactionReportIDs.includes(transaction.reportID));
return Object.values(transactions ?? {}).filter((transaction): transaction is Transaction => !!transaction && tripTransactionReportIDs.includes(transaction.reportID));
},
},
});

[tripTransactionReportIDs],
);
return tripTransactions;
}

Expand Down

0 comments on commit 4cf24c5

Please sign in to comment.