diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index d7412e596614..785796cbf1f2 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -967,6 +967,7 @@ function openReport( transaction?: Transaction, transactionViolations?: TransactionViolations, parentReportID?: string, + shouldAddPendingFields = true, ) { if (!reportID) { return; @@ -1216,10 +1217,12 @@ function openReport( ...optimisticReport, reportName: CONST.REPORT.DEFAULT_REPORT_NAME, ...newReportObject, - pendingFields: { - createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, - ...(isGroupChat && {reportName: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}), - }, + pendingFields: shouldAddPendingFields + ? { + createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, + ...(isGroupChat && {reportName: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}), + } + : undefined, }; } @@ -1232,7 +1235,7 @@ function openReport( { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, - value: {[optimisticCreatedAction.reportActionID]: optimisticCreatedAction}, + value: {[optimisticCreatedAction.reportActionID]: {...optimisticCreatedAction, pendingAction: shouldAddPendingFields ? CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD : null}}, }, { onyxMethod: Onyx.METHOD.SET, @@ -1414,6 +1417,7 @@ function createTransactionThreadReport( const optimisticTransactionThreadReportID = generateReportID(); const optimisticTransactionThread = buildTransactionThread(iouReportAction, reportToUse, undefined, optimisticTransactionThreadReportID); + const shouldAddPendingFields = transaction?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD || iouReportAction?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD; openReport( optimisticTransactionThreadReportID, undefined, @@ -1427,6 +1431,7 @@ function createTransactionThreadReport( transaction, transactionViolations, selfDMReportID, + shouldAddPendingFields, ); return optimisticTransactionThread; }