@@ -17,18 +17,20 @@ import useSelectedTransactionsActions from '@hooks/useSelectedTransactionsAction
1717import useTheme from '@hooks/useTheme' ;
1818import useThemeStyles from '@hooks/useThemeStyles' ;
1919import { turnOffMobileSelectionMode } from '@libs/actions/MobileSelectionMode' ;
20- import { deleteAppReport , downloadReportPDF , exportReportToCSV , exportReportToPDF , exportToIntegration , markAsManuallyExported , openUnreportedExpense } from '@libs/actions/Report' ;
20+ import { deleteAppReport , downloadReportPDF , exportReportToCSV , exportReportToPDF , exportToIntegration , markAsManuallyExported , openReport , openUnreportedExpense } from '@libs/actions/Report' ;
2121import { getThreadReportIDsForTransactions , getTotalAmountForIOUReportPreviewButton } from '@libs/MoneyRequestReportUtils' ;
2222import Navigation from '@libs/Navigation/Navigation' ;
2323import { buildOptimisticNextStepForPreventSelfApprovalsEnabled } from '@libs/NextStepUtils' ;
2424import { isSecondaryActionAPaymentOption , selectPaymentType } from '@libs/PaymentUtils' ;
2525import type { KYCFlowEvent , TriggerKYCFlow } from '@libs/PaymentUtils' ;
2626import { getValidConnectedIntegration } from '@libs/PolicyUtils' ;
27- import { getOriginalMessage , getReportAction , isMoneyRequestAction } from '@libs/ReportActionsUtils' ;
27+ import { getIOUActionForReportID , getOriginalMessage , getReportAction , isMoneyRequestAction } from '@libs/ReportActionsUtils' ;
2828import { getAllExpensesToHoldIfApplicable , getReportPrimaryAction } from '@libs/ReportPrimaryActionUtils' ;
2929import { getSecondaryReportActions } from '@libs/ReportSecondaryActionUtils' ;
3030import {
31+ buildTransactionThread ,
3132 changeMoneyRequestHoldStatus ,
33+ generateReportID ,
3234 getArchiveReason ,
3335 getBankAccountRoute ,
3436 getIntegrationIcon ,
@@ -612,9 +614,14 @@ function MoneyReportHeader({
612614 success
613615 text = { translate ( 'iou.reviewDuplicates' ) }
614616 onPress = { ( ) => {
615- const threadID = transactionThreadReportID ?? getFirstDuplicateThreadID ( transactions , reportActions ) ;
617+ let threadID = transactionThreadReportID ?? getFirstDuplicateThreadID ( transactions , reportActions ) ;
616618 if ( ! threadID ) {
617- return ;
619+ threadID = generateReportID ( ) ;
620+ const duplicateTransaction = transactions . find ( ( reportTransaction ) => isDuplicate ( reportTransaction ) ) ;
621+ const transactionID = duplicateTransaction ?. transactionID ;
622+ const iouAction = getIOUActionForReportID ( moneyRequestReport ?. reportID , transactionID ) ;
623+ const optimisticTransactionThread = buildTransactionThread ( iouAction , moneyRequestReport , undefined , threadID ) ;
624+ openReport ( threadID , undefined , session ?. email ? [ session ?. email ] : [ ] , optimisticTransactionThread , iouAction ?. reportActionID ) ;
618625 }
619626 Navigation . navigate ( ROUTES . TRANSACTION_DUPLICATE_REVIEW_PAGE . getRoute ( threadID ) ) ;
620627 } }
0 commit comments