Skip to content

Commit

Permalink
fix crash if report doesnt have transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
luacmartins committed Jun 6, 2024
1 parent f2018b8 commit 937b638
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/SelectionList/Search/ReportListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,18 @@ function ReportListItem<TItem extends ListItem>({
return null;
}

const participantFrom = reportItem.transactions[0].from;
const participantTo = reportItem.transactions[0].to;
const participantFrom = reportItem.transactions[0]?.from;
const participantTo = reportItem.transactions[0]?.to;

// These values should come as part of the item via SearchUtils.getSections() but ReportListItem is not yet 100% handled
// This will be simplified in future once sorting of ReportListItem is done
const participantFromDisplayName = participantFrom?.name ?? participantFrom?.displayName ?? participantFrom?.login ?? '';
const participantToDisplayName = participantTo?.name ?? participantTo?.displayName ?? participantTo?.login ?? '';

if (reportItem.transactions.length === 0) {
return;
}

if (reportItem.transactions.length === 1) {
const transactionItem = reportItem.transactions[0];

Expand Down

0 comments on commit 937b638

Please sign in to comment.