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
8 changes: 7 additions & 1 deletion src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4798,8 +4798,14 @@ function markAsManuallyExported(reportID: string, connectionName: ConnectionName
}

function exportReportToCSV({reportID, transactionIDList}: ExportReportCSVParams, onDownloadFailed: () => void) {
let reportIDParam = reportID;
const allReportTransactions = getReportTransactions(reportID).filter((transaction) => transaction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);
const allTransactionIDs = allReportTransactions.map((transaction) => transaction.transactionID);
if (allTransactionIDs.length !== transactionIDList.length) {
reportIDParam = '-1';
}
const finalParameters = enhanceParameters(WRITE_COMMANDS.EXPORT_REPORT_TO_CSV, {
reportID,
reportID: reportIDParam,
transactionIDList,
});

Expand Down
15 changes: 13 additions & 2 deletions src/libs/actions/Search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {rand64} from '@libs/NumberUtils';
import {getPersonalPolicy, getSubmitToAccountID, getValidConnectedIntegration} from '@libs/PolicyUtils';
import {getIOUActionForTransactionID} from '@libs/ReportActionsUtils';
import type {OptimisticExportIntegrationAction} from '@libs/ReportUtils';
import {buildOptimisticExportIntegrationAction, hasHeldExpenses, isExpenseReport, isInvoiceReport, isIOUReport as isIOUReportUtil} from '@libs/ReportUtils';
import {buildOptimisticExportIntegrationAction, getReportTransactions, hasHeldExpenses, isExpenseReport, isInvoiceReport, isIOUReport as isIOUReportUtil} from '@libs/ReportUtils';
import type {SearchKey} from '@libs/SearchUIUtils';
import {isTransactionGroupListItemType, isTransactionListItemType} from '@libs/SearchUIUtils';
import playSound, {SOUNDS} from '@libs/Sound';
Expand Down Expand Up @@ -519,10 +519,21 @@ function deleteMoneyRequestOnSearch(hash: number, transactionIDList: string[]) {
type Params = Record<string, ExportSearchItemsToCSVParams>;

function exportSearchItemsToCSV({query, jsonQuery, reportIDList, transactionIDList}: ExportSearchItemsToCSVParams, onDownloadFailed: () => void) {
const reportIDListParams: string[] = [];
reportIDList.forEach((reportID) => {
const allReportTransactions = getReportTransactions(reportID).filter((transaction) => transaction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);
const allTransactionIDs = allReportTransactions.map((transaction) => transaction.transactionID);
if (allTransactionIDs.every((transactionID) => transactionIDList.includes(transactionID))) {
if (reportIDListParams.includes(reportID)) {
return;
}
reportIDListParams.push(reportID);
}
});
const finalParameters = enhanceParameters(WRITE_COMMANDS.EXPORT_SEARCH_ITEMS_TO_CSV, {
query,
jsonQuery,
reportIDList,
reportIDList: reportIDListParams,
transactionIDList,
}) as Params;

Expand Down