diff --git a/src/components/MoneyRequestReportView/SelectionToolbar/index.tsx b/src/components/MoneyRequestReportView/SelectionToolbar/index.tsx index bcc5cdaa2b95..975c9d346e8c 100644 --- a/src/components/MoneyRequestReportView/SelectionToolbar/index.tsx +++ b/src/components/MoneyRequestReportView/SelectionToolbar/index.tsx @@ -82,7 +82,7 @@ function SelectionToolbar({reportID, transactions, reportActions}: SelectionTool const isMobileSelectionModeEnabled = useMobileSelectionMode(); const {showConfirmModal} = useConfirmModal(); - const {trackExport, exportDownloadStatusModal} = useExportDownloadStatusModal(() => clearSelectedTransactions(undefined, true)); + const {trackExport, exportDownloadStatusModal} = useExportDownloadStatusModal(() => clearSelectedTransactions(true)); const [offlineModalVisible, setOfflineModalVisible] = useState(false); const [isDownloadErrorModalVisible, setIsDownloadErrorModalVisible] = useState(false); diff --git a/src/hooks/useExportActions.ts b/src/hooks/useExportActions.ts index 6aebeec017c9..6d56968c3209 100644 --- a/src/hooks/useExportActions.ts +++ b/src/hooks/useExportActions.ts @@ -74,7 +74,7 @@ function useExportActions({reportID, policy, onPDFModalOpen}: UseExportActionsPa const {showDecisionModal} = useDecisionModal(); const {triggerExportOrConfirm} = useExportAgainModal(moneyRequestReport?.reportID, moneyRequestReport?.policyID); const {clearSelectedTransactions} = useSearchSelectionActions(); - const {trackExport, exportDownloadStatusModal} = useExportDownloadStatusModal(() => clearSelectedTransactions(undefined, true)); + const {trackExport, exportDownloadStatusModal} = useExportDownloadStatusModal(() => clearSelectedTransactions(true)); const expensifyIcons = useMemoizedLazyExpensifyIcons([ 'Table', diff --git a/tests/unit/hooks/useExportActionsTest.ts b/tests/unit/hooks/useExportActionsTest.ts index 0764ea2decad..38f984e7348b 100644 --- a/tests/unit/hooks/useExportActionsTest.ts +++ b/tests/unit/hooks/useExportActionsTest.ts @@ -156,4 +156,21 @@ describe('useExportActions - template export status modal', () => { expect(mockClearExportDownload).toHaveBeenCalledWith('mock-export-id', undefined); expect(result.current.exportDownloadStatusModal).toBeNull(); }); + + it('clears the report-view selection with the boolean flag when the status modal is dismissed', () => { + const {result} = renderHook(() => useExportActions({reportID: REPORT_ID})); + + act(() => { + result.current.beginExportWithTemplate('Test Template', 'csv', ['1'], EXPORT_NAME, POLICY_ID); + }); + const modal: ReactElement | null = result.current.exportDownloadStatusModal; + + act(() => { + modal?.props.onClose(); + }); + + // The cleanup callback must call clearSelectedTransactions with the boolean `true` (not `(undefined, true)`), + // because the selection API only resets the report-view selection when the first argument is a boolean. + expect(mockClearSelectedTransactions).toHaveBeenCalledWith(true); + }); });