Skip to content

Commit

Permalink
fix to field on reportListItem
Browse files Browse the repository at this point in the history
  • Loading branch information
luacmartins committed Jul 9, 2024
1 parent ae20667 commit 1b04a52
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/libs/SearchUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,20 @@ function getReportSections(data: OnyxTypes.SearchResults['data'], metadata: Onyx
const reportIDToTransactions: Record<string, ReportListItemType> = {};
for (const key in data) {
if (key.startsWith(ONYXKEYS.COLLECTION.REPORT)) {
const value = {...data[key]};
const reportKey = `${ONYXKEYS.COLLECTION.REPORT}${value.reportID}`;
const reportItem = {...data[key]};
const reportKey = `${ONYXKEYS.COLLECTION.REPORT}${reportItem.reportID}`;
const transactions = reportIDToTransactions[reportKey]?.transactions ?? [];
const isExpenseReport = reportItem.type === CONST.REPORT.TYPE.EXPENSE;

const to = isExpenseReport
? (data[`${ONYXKEYS.COLLECTION.POLICY}${reportItem.policyID}`] as SearchAccountDetails)
: (data.personalDetailsList?.[reportItem.managerID] as SearchAccountDetails);

reportIDToTransactions[reportKey] = {
...value,
keyForList: value.reportID,
from: data.personalDetailsList?.[value.accountID],
to: data.personalDetailsList?.[value.managerID],
...reportItem,
keyForList: reportItem.reportID,
from: data.personalDetailsList?.[reportItem.accountID],
to,
transactions,
};
} else if (key.startsWith(ONYXKEYS.COLLECTION.TRANSACTION)) {
Expand Down
5 changes: 4 additions & 1 deletion src/types/onyx/SearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,17 @@ type SearchReport = {
currency?: string;

/** The report type */
type?: string;
type?: ValueOf();

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

View workflow job for this annotation

GitHub Actions / typecheck

';' expected.

/** The accountID of the report manager */
managerID?: number;

/** The accountID of the user who created the report */
accountID?: number;

/** The policyID of the report */
policyID?: ValueOf<typeof CONST.REPORT.TYPE>;

/** The date the report was created */
created?: string;

Expand Down

0 comments on commit 1b04a52

Please sign in to comment.