@@ -18,6 +18,7 @@ import useDefaultExpensePolicy from '@hooks/useDefaultExpensePolicy';
1818import useDeleteTransactions from '@hooks/useDeleteTransactions' ;
1919import useDuplicateTransactionsAndViolations from '@hooks/useDuplicateTransactionsAndViolations' ;
2020import useEnvironment from '@hooks/useEnvironment' ;
21+ import useExportAgainModal from '@hooks/useExportAgainModal' ;
2122import useGetIOUReportFromReportAction from '@hooks/useGetIOUReportFromReportAction' ;
2223import { useMemoizedLazyExpensifyIcons } from '@hooks/useLazyAsset' ;
2324import useLocalize from '@hooks/useLocalize' ;
@@ -128,7 +129,6 @@ import {
128129 isPerDiemRequest ,
129130 isTransactionPendingDelete ,
130131} from '@libs/TransactionUtils' ;
131- import type { ExportType } from '@pages/inbox/report/ReportDetailsExportPage' ;
132132import {
133133 approveMoneyRequest ,
134134 canApproveIOU ,
@@ -377,8 +377,8 @@ function MoneyReportHeader({reportID: reportIDProp, shouldDisplayBackButton = fa
377377 const hasCustomUnitOutOfPolicyViolation = hasCustomUnitOutOfPolicyViolationTransactionUtils ( transactionViolations ) ;
378378 const isPerDiemRequestOnNonDefaultWorkspace = isPerDiemRequest ( transaction ) && defaultExpensePolicy ?. id !== policy ?. id ;
379379
380- const [ exportModalStatus , setExportModalStatus ] = useState < ExportType | null > ( null ) ;
381380 const { showConfirmModal} = useConfirmModal ( ) ;
381+ const { triggerExportOrConfirm} = useExportAgainModal ( moneyRequestReport ?. reportID , moneyRequestReport ?. policyID ) ;
382382 const { showDecisionModal} = useDecisionModal ( ) ;
383383
384384 const showOfflineModal = ( ) => {
@@ -1027,18 +1027,6 @@ function MoneyReportHeader({reportID: reportIDProp, shouldDisplayBackButton = fa
10271027 bankAccountList ,
10281028 ] ) ;
10291029
1030- const confirmExport = useCallback ( ( ) => {
1031- setExportModalStatus ( null ) ;
1032- if ( ! moneyRequestReport ?. reportID || ! connectedIntegration ) {
1033- return ;
1034- }
1035- if ( exportModalStatus === CONST . REPORT . EXPORT_OPTIONS . EXPORT_TO_INTEGRATION ) {
1036- exportToIntegration ( moneyRequestReport ?. reportID , connectedIntegration ) ;
1037- } else if ( exportModalStatus === CONST . REPORT . EXPORT_OPTIONS . MARK_AS_EXPORTED ) {
1038- markAsManuallyExported ( [ moneyRequestReport ?. reportID ?? CONST . DEFAULT_NUMBER_ID ] , connectedIntegration ) ;
1039- }
1040- } , [ connectedIntegration , exportModalStatus , moneyRequestReport ?. reportID ] ) ;
1041-
10421030 const getAmount = ( actionType : ValueOf < typeof CONST . REPORT . REPORT_PREVIEW_ACTIONS > ) => ( {
10431031 formattedAmount : getTotalAmountForIOUReportPreviewButton ( moneyRequestReport , policy , actionType , nonPendingDeleteTransactions ) ,
10441032 } ) ;
@@ -1171,7 +1159,7 @@ function MoneyReportHeader({reportID: reportIDProp, shouldDisplayBackButton = fa
11711159 return ;
11721160 }
11731161 if ( isExported ) {
1174- setExportModalStatus ( CONST . REPORT . EXPORT_OPTIONS . EXPORT_TO_INTEGRATION ) ;
1162+ triggerExportOrConfirm ( CONST . REPORT . EXPORT_OPTIONS . EXPORT_TO_INTEGRATION ) ;
11751163 return ;
11761164 }
11771165 exportToIntegration ( moneyRequestReport ?. reportID , connectedIntegration ) ;
@@ -1191,7 +1179,7 @@ function MoneyReportHeader({reportID: reportIDProp, shouldDisplayBackButton = fa
11911179 return ;
11921180 }
11931181 if ( isExported ) {
1194- setExportModalStatus ( CONST . REPORT . EXPORT_OPTIONS . MARK_AS_EXPORTED ) ;
1182+ triggerExportOrConfirm ( CONST . REPORT . EXPORT_OPTIONS . MARK_AS_EXPORTED ) ;
11951183 return ;
11961184 }
11971185 markAsManuallyExported ( [ moneyRequestReport ?. reportID ?? CONST . DEFAULT_NUMBER_ID ] , connectedIntegration ) ;
@@ -1223,6 +1211,7 @@ function MoneyReportHeader({reportID: reportIDProp, shouldDisplayBackButton = fa
12231211 isExported ,
12241212 exportTemplates ,
12251213 beginExportWithTemplate ,
1214+ triggerExportOrConfirm ,
12261215 showDecisionModal ,
12271216 ] ) ;
12281217
@@ -1250,7 +1239,7 @@ function MoneyReportHeader({reportID: reportIDProp, shouldDisplayBackButton = fa
12501239 setIsHoldMenuVisible ( true ) ;
12511240 }
12521241 } }
1253- onExportModalOpen = { ( ) => setExportModalStatus ( CONST . REPORT . EXPORT_OPTIONS . EXPORT_TO_INTEGRATION ) }
1242+ onExportModalOpen = { ( ) => triggerExportOrConfirm ( CONST . REPORT . EXPORT_OPTIONS . EXPORT_TO_INTEGRATION ) }
12541243 />
12551244 ) ;
12561245
@@ -2002,34 +1991,6 @@ function MoneyReportHeader({reportID: reportIDProp, shouldDisplayBackButton = fa
20021991 chatReport ?. reportID ,
20031992 ] ) ;
20041993
2005- const showExportAgainModal = useCallback ( ( ) => {
2006- if ( ! connectedIntegration ) {
2007- return ;
2008- }
2009- showConfirmModal ( {
2010- title : translate ( 'workspace.exportAgainModal.title' ) ,
2011- prompt : translate ( 'workspace.exportAgainModal.description' , {
2012- connectionName : connectedIntegration ?? connectedIntegrationFallback ,
2013- reportName : moneyRequestReport ?. reportName ?? '' ,
2014- } ) ,
2015- confirmText : translate ( 'workspace.exportAgainModal.confirmText' ) ,
2016- cancelText : translate ( 'workspace.exportAgainModal.cancelText' ) ,
2017- } ) . then ( ( result ) => {
2018- if ( result . action !== ModalActions . CONFIRM ) {
2019- setExportModalStatus ( null ) ;
2020- return ;
2021- }
2022- confirmExport ( ) ;
2023- } ) ;
2024- } , [ showConfirmModal , translate , connectedIntegration , connectedIntegrationFallback , moneyRequestReport ?. reportName , confirmExport ] ) ;
2025-
2026- useEffect ( ( ) => {
2027- if ( ! exportModalStatus ) {
2028- return ;
2029- }
2030- showExportAgainModal ( ) ;
2031- } , [ exportModalStatus , showExportAgainModal ] ) ;
2032-
20331994 const allExpensesSelected = selectedTransactionIDs . length > 0 && selectedTransactionIDs . length === nonPendingDeleteTransactions . length ;
20341995
20351996 const selectedTransactionsOptions = useMemo ( ( ) => {
0 commit comments