Skip to content

Commit

Permalink
Merge pull request #45105 from Expensify/cmartins-fixToFieldOnReports
Browse files Browse the repository at this point in the history
Fix to field on reportListItem
  • Loading branch information
carlosmiceli authored Jul 12, 2024
2 parents 5b81bae + 16de7cf commit 5b436d9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function TotalCell({showTooltip, isLargeScreenWidth, transactionItem}: TotalCell

function TypeCell({transactionItem, isLargeScreenWidth}: TransactionCellProps) {
const theme = useTheme();
const typeIcon = getTypeIcon(transactionItem.type);
const typeIcon = getTypeIcon(transactionItem.transactionType);

return (
<Icon
Expand Down
19 changes: 12 additions & 7 deletions src/libs/SearchUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const columnNamesToSortingProperty = {
[CONST.SEARCH.TABLE_COLUMNS.MERCHANT]: 'formattedMerchant' as const,
[CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]: 'formattedTotal' as const,
[CONST.SEARCH.TABLE_COLUMNS.CATEGORY]: 'category' as const,
[CONST.SEARCH.TABLE_COLUMNS.TYPE]: 'type' as const,
[CONST.SEARCH.TABLE_COLUMNS.TYPE]: 'transactionType' as const,
[CONST.SEARCH.TABLE_COLUMNS.ACTION]: 'action' as const,
[CONST.SEARCH.TABLE_COLUMNS.DESCRIPTION]: 'comment' as const,
[CONST.SEARCH.TABLE_COLUMNS.TAX_AMOUNT]: null,
Expand Down Expand Up @@ -160,15 +160,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
7 changes: 5 additions & 2 deletions src/types/onyx/SearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,17 @@ type SearchReport = {
currency?: string;

/** The report type */
type?: string;
type?: ValueOf<typeof CONST.REPORT.TYPE>;

/** 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?: string;

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

Expand Down Expand Up @@ -180,7 +183,7 @@ type SearchTransaction = {
category: string;

/** The type of request */
type: ValueOf<typeof CONST.SEARCH.TRANSACTION_TYPE>;
transactionType: ValueOf<typeof CONST.SEARCH.TRANSACTION_TYPE>;

/** The type of report the transaction is associated with */
reportType: string;
Expand Down

0 comments on commit 5b436d9

Please sign in to comment.