Skip to content

Commit

Permalink
Merge pull request #44658 from c3024/get-correct-from-and-to-for-repo…
Browse files Browse the repository at this point in the history
…rt-from-first-transaction

correct logic of `from` and `to` for narrow layout in `Shared` in `Search`
  • Loading branch information
luacmartins authored Jul 3, 2024
2 parents be213df + ad2e78a commit d30a4bc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
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];
}
}
}
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 @@ -121,6 +121,12 @@ type SearchReport = {

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

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

Check failure on line 126 in src/types/onyx/SearchResults.ts

View workflow job for this annotation

GitHub Actions / typecheck / typecheck

Duplicate identifier 'accountID'.

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

Check failure on line 129 in src/types/onyx/SearchResults.ts

View workflow job for this annotation

GitHub Actions / typecheck / typecheck

Duplicate identifier 'managerID'.
};

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

0 comments on commit d30a4bc

Please sign in to comment.