diff --git a/src/components/Search/SearchPageHeader.tsx b/src/components/Search/SearchPageHeader.tsx index 7e4b69c39596..bae08155c262 100644 --- a/src/components/Search/SearchPageHeader.tsx +++ b/src/components/Search/SearchPageHeader.tsx @@ -157,9 +157,12 @@ function SearchPageHeader({queryJSON, hash, onSelectDeleteOption, setOfflineModa } const reportIDList = (selectedReports?.filter((report) => !!report) as string[]) ?? []; - SearchActions.exportSearchItemsToCSV({query: status, reportIDList, transactionIDList: selectedTransactionsKeys, policyIDs: [activeWorkspaceID ?? '']}, () => { - setDownloadErrorModalOpen?.(); - }); + SearchActions.exportSearchItemsToCSV( + {query: status, jsonQuery: JSON.stringify(queryJSON), reportIDList, transactionIDList: selectedTransactionsKeys, policyIDs: [activeWorkspaceID ?? '']}, + () => { + setDownloadErrorModalOpen?.(); + }, + ); }, }); @@ -247,6 +250,7 @@ function SearchPageHeader({queryJSON, hash, onSelectDeleteOption, setOfflineModa return options; }, [ + queryJSON, status, selectedTransactionsKeys, selectedTransactions, diff --git a/src/libs/API/parameters/ExportSearchItemsToCSVParams.ts b/src/libs/API/parameters/ExportSearchItemsToCSVParams.ts index 2659fac6810a..057b6188e3ea 100644 --- a/src/libs/API/parameters/ExportSearchItemsToCSVParams.ts +++ b/src/libs/API/parameters/ExportSearchItemsToCSVParams.ts @@ -1,7 +1,8 @@ -import type {SearchStatus} from '@components/Search/types'; +import type {SearchQueryString, SearchStatus} from '@components/Search/types'; type ExportSearchItemsToCSVParams = { query: SearchStatus; + jsonQuery: SearchQueryString; reportIDList: string[]; transactionIDList: string[]; policyIDs: string[]; diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 040fd6e47491..b51955c9cc59 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -97,9 +97,10 @@ function deleteMoneyRequestOnSearch(hash: number, transactionIDList: string[]) { type Params = Record; -function exportSearchItemsToCSV({query, reportIDList, transactionIDList, policyIDs}: ExportSearchItemsToCSVParams, onDownloadFailed: () => void) { +function exportSearchItemsToCSV({query, jsonQuery, reportIDList, transactionIDList, policyIDs}: ExportSearchItemsToCSVParams, onDownloadFailed: () => void) { const finalParameters = enhanceParameters(WRITE_COMMANDS.EXPORT_SEARCH_ITEMS_TO_CSV, { query, + jsonQuery, reportIDList, transactionIDList, policyIDs,