diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 82eecae2bf9d..cf36cf7383a8 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, optimisticSelfDMReport?: Report, ) { if (!reportID) { @@ -1232,10 +1233,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, }; } @@ -1248,7 +1251,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, @@ -1437,6 +1440,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, @@ -1450,6 +1454,7 @@ function createTransactionThreadReport( transaction, transactionViolations, selfDMReportID, + shouldAddPendingFields, optimisticSelfDMReport, ); return optimisticTransactionThread;