From 69ae465f2ebff344ab8338b66e55761c67fd15ed Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sat, 7 Sep 2024 00:42:36 +0700 Subject: [PATCH 1/2] fix failed to create main chat isn't cleared when dismiss transaction create error --- .../ReportActionItem/MoneyRequestView.tsx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 57c5c01da55d..15c28e06af52 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -467,20 +467,15 @@ function MoneyRequestView({ return; } - const isCreateChatErrored = !!report?.errorFields?.createChat; - if ((isCreateChatErrored || !!report?.isOptimisticReport) && parentReportAction) { - const urlToNavigateBack = IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true); - Navigation.goBack(urlToNavigateBack); - return; - } - if (transaction?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) { if (chatReport?.reportID && ReportUtils.getAddWorkspaceRoomOrChatReportErrors(chatReport)) { Report.navigateToConciergeChatAndDeleteReport(chatReport.reportID, true, true); return; } - if (Object.values(transaction?.errors ?? {})?.find((error) => ErrorUtils.isReceiptError(error))) { - deleteTransaction(parentReport, parentReportAction); + if (parentReportAction) { + const urlToNavigateBack = IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true); + Navigation.goBack(urlToNavigateBack); + return; } } Transaction.clearError(transaction?.transactionID ?? linkedTransactionID); From af09bc1abbf08376860c7c0df31c3931167eee77 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sat, 7 Sep 2024 01:09:46 +0700 Subject: [PATCH 2/2] remove unused code --- .../ReportActionItem/MoneyRequestView.tsx | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 15c28e06af52..5c17951c3fde 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -22,7 +22,6 @@ import type {ViolationField} from '@hooks/useViolations'; import * as CurrencyUtils from '@libs/CurrencyUtils'; import type {MileageRate} from '@libs/DistanceRequestUtils'; import DistanceRequestUtils from '@libs/DistanceRequestUtils'; -import * as ErrorUtils from '@libs/ErrorUtils'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PolicyUtils from '@libs/PolicyUtils'; import {isTaxTrackingEnabled} from '@libs/PolicyUtils'; @@ -97,18 +96,6 @@ const receiptImageViolationNames: OnyxTypes.ViolationName[] = [ const receiptFieldViolationNames: OnyxTypes.ViolationName[] = [CONST.VIOLATIONS.MODIFIED_AMOUNT, CONST.VIOLATIONS.MODIFIED_DATE]; -const deleteTransaction = (parentReport: OnyxEntry, parentReportAction: OnyxEntry) => { - if (!parentReportAction) { - return; - } - const iouTransactionID = ReportActionsUtils.isMoneyRequestAction(parentReportAction) ? ReportActionsUtils.getOriginalMessage(parentReportAction)?.IOUTransactionID ?? '-1' : '-1'; - if (ReportActionsUtils.isTrackExpenseAction(parentReportAction)) { - IOU.deleteTrackExpense(parentReport?.reportID ?? '-1', iouTransactionID, parentReportAction, true); - return; - } - IOU.deleteMoneyRequest(iouTransactionID, parentReportAction, true); -}; - const getTransactionID = (report: OnyxEntry, parentReportActions: OnyxEntry) => { const parentReportAction = parentReportActions?.[report?.parentReportActionID ?? '-1']; const originalMessage = parentReportAction && ReportActionsUtils.isMoneyRequestAction(parentReportAction) ? ReportActionsUtils.getOriginalMessage(parentReportAction) : undefined;