From 337aede449d782abf7125ec775616204b3d52f9e Mon Sep 17 00:00:00 2001 From: Nam Le Date: Mon, 4 Sep 2023 20:20:33 +0700 Subject: [PATCH] fix close message --- src/libs/actions/ReportActions.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/ReportActions.js b/src/libs/actions/ReportActions.js index 55d81cb6eb14..d270876840ac 100644 --- a/src/libs/actions/ReportActions.js +++ b/src/libs/actions/ReportActions.js @@ -2,20 +2,23 @@ import Onyx from 'react-native-onyx'; import ONYXKEYS from '../../ONYXKEYS'; import CONST from '../../CONST'; import * as ReportActionUtils from '../ReportActionsUtils'; +import * as ReportUtils from '../ReportUtils'; /** * @param {String} reportID * @param {Object} reportAction */ function clearReportActionErrors(reportID, reportAction) { + const originalReportID = ReportUtils.getOriginalReportID(reportID, reportAction); + if (reportAction.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) { // Delete the optimistic action - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, { + Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, { [reportAction.reportActionID]: null, }); // If there's a linked transaction, delete that too - const linkedTransactionID = ReportActionUtils.getLinkedTransactionID(reportID, reportAction.reportActionID); + const linkedTransactionID = ReportActionUtils.getLinkedTransactionID(originalReportID, reportAction.reportActionID); if (linkedTransactionID) { Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION}${linkedTransactionID}`, null); } @@ -23,7 +26,7 @@ function clearReportActionErrors(reportID, reportAction) { return; } - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, { + Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, { [reportAction.reportActionID]: { errors: null, },