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
2 changes: 2 additions & 0 deletions src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function mapTransactionItemToSelectedEntry(
policyID: item.policyID,
amount: item.modifiedAmount ?? item.amount,
convertedAmount: item.convertedAmount,
isFromOneTransactionReport: item.isFromOneTransactionReport,
convertedCurrency: item.convertedCurrency,
},
];
Expand Down Expand Up @@ -184,6 +185,7 @@ function prepareTransactionsList(
amount: Math.abs(item.modifiedAmount || item.amount),
convertedAmount: item.convertedAmount,
convertedCurrency: item.convertedCurrency,
isFromOneTransactionReport: item.isFromOneTransactionReport,
},
};
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/Search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ type SelectedTransactionInfo = {

/** The currency that the converted amount is in */
convertedCurrency: string;

/** Whether it is the only expense of the parent expense report */
isFromOneTransactionReport?: boolean;
};

/** Model of selected transactions */
Expand Down
7 changes: 5 additions & 2 deletions src/pages/Search/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,12 @@ function SearchPage({route}: SearchPageProps) {
const areFullReportsSelected = selectedTransactionReportIDs.length === selectedReportIDs.length && selectedTransactionReportIDs.every((id) => selectedReportIDs.includes(id));
const groupByReports = queryJSON?.groupBy === CONST.SEARCH.GROUP_BY.REPORTS;
const typeInvoice = queryJSON?.type === CONST.REPORT.TYPE.INVOICE;
const typeExpense = queryJSON?.type === CONST.REPORT.TYPE.EXPENSE;
const isAllOneTransactionReport = Object.values(selectedTransactions).every((transaction) => transaction.isFromOneTransactionReport);

// If we're grouping by invoice or report, and all the expenses on the report are selected, include the report level export option
const includeReportLevelExport = (groupByReports || typeInvoice) && areFullReportsSelected;
// If we're grouping by invoice or report, and all the expenses on the report are selected, or if all
// the selected expenses are the only expenses of their parent expense report include the report level export option.
const includeReportLevelExport = ((groupByReports || typeInvoice) && areFullReportsSelected) || (typeExpense && !groupByReports && isAllOneTransactionReport);

// Collate a list of policyIDs from the selected transactions
const selectedPolicyIDs = [
Expand Down
Loading