Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/components/SelectionList/Search/ReportListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ function ReportListItem<TItem extends ListItem>({
return null;
}

const participantFrom = reportItem.transactions[0].from;
const participantTo = reportItem.transactions[0].to;
const participantFrom = reportItem.from;
const participantTo = reportItem.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
Expand Down
6 changes: 6 additions & 0 deletions src/components/SelectionList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ type TransactionListItemType = ListItem &

type ReportListItemType = ListItem &
SearchReport & {
/** The personal details of the user requesting money */
from: SearchAccountDetails;

/** The personal details of the user paying the request */
to: SearchAccountDetails;

transactions: TransactionListItemType[];
};

Expand Down
4 changes: 3 additions & 1 deletion src/libs/SearchUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ function getReportSections(data: OnyxTypes.SearchResults['data'], metadata: Onyx

reportIDToTransactions[reportKey] = {
...value,
from: data.personalDetailsList?.[value.accountID],
to: data.personalDetailsList?.[value.managerID],
transactions,
};
} else if (key.startsWith(ONYXKEYS.COLLECTION.TRANSACTION)) {
Expand Down Expand Up @@ -199,7 +201,7 @@ function getReportSections(data: OnyxTypes.SearchResults['data'], metadata: Onyx
if (reportIDToTransactions[reportKey]?.transactions) {
reportIDToTransactions[reportKey].transactions.push(transaction);
} else {
reportIDToTransactions[reportKey] = {transactions: [transaction]};
reportIDToTransactions[reportKey].transactions = [transaction];
}
Comment on lines 203 to 205

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This caused App crash when BE sends a transaction with missing report (reportIDToTransactions[reportKey] can be undefined). Issue: #46516 PR: #46867

}
}
Expand Down
6 changes: 6 additions & 0 deletions src/types/onyx/SearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ type SearchReport = {

/** The action that can be performed for the report */
action?: string;

/** The net report sender ID */
accountID?: number;

/** The net report recipient ID */
managerID?: number;
};

/** Model of transaction search result */
Expand Down