Skip to content

Commit 1df0549

Browse files
committed
generate thread if needed
1 parent a839211 commit 1df0549

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/components/MoneyReportHeader.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@ import useSelectedTransactionsActions from '@hooks/useSelectedTransactionsAction
1717
import useTheme from '@hooks/useTheme';
1818
import useThemeStyles from '@hooks/useThemeStyles';
1919
import {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';
2121
import {getThreadReportIDsForTransactions, getTotalAmountForIOUReportPreviewButton} from '@libs/MoneyRequestReportUtils';
2222
import Navigation from '@libs/Navigation/Navigation';
2323
import {buildOptimisticNextStepForPreventSelfApprovalsEnabled} from '@libs/NextStepUtils';
2424
import {isSecondaryActionAPaymentOption, selectPaymentType} from '@libs/PaymentUtils';
2525
import type {KYCFlowEvent, TriggerKYCFlow} from '@libs/PaymentUtils';
2626
import {getValidConnectedIntegration} from '@libs/PolicyUtils';
27-
import {getOriginalMessage, getReportAction, isMoneyRequestAction} from '@libs/ReportActionsUtils';
27+
import {getIOUActionForReportID, getOriginalMessage, getReportAction, isMoneyRequestAction} from '@libs/ReportActionsUtils';
2828
import {getAllExpensesToHoldIfApplicable, getReportPrimaryAction} from '@libs/ReportPrimaryActionUtils';
2929
import {getSecondaryReportActions} from '@libs/ReportSecondaryActionUtils';
3030
import {
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

Comments
 (0)