Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to field on reportListItem #45105

Merged
merged 3 commits into from
Jul 12, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,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 @@ -25,7 +25,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 @@ -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
7 changes: 5 additions & 2 deletions 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<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 @@ -177,7 +180,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
Loading