From 6d6a8644f5be16e72779b6e32b35dd01341fc821 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 13 Oct 2025 00:11:40 +0700 Subject: [PATCH 1/2] fix: GBR is not displayed in workspace chat after changing workspace of a report --- src/libs/actions/Report.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 48d4ac585d2a..126800b5e718 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -154,6 +154,7 @@ import { hasOutstandingChildRequest, isChatThread as isChatThreadReportUtils, isConciergeChatReport, + isCurrentUserSubmitter, isExpenseReport, isGroupChat as isGroupChatReportUtils, isHiddenForCurrentUser, @@ -5821,6 +5822,15 @@ function buildOptimisticChangePolicyData( }); } + let shouldSetOutstandingChildRequest = false; + if (newStatusNum === CONST.REPORT.STATUS_NUM.OPEN || isOpenOrSubmitted) { + if (newStatusNum === CONST.REPORT.STATUS_NUM.OPEN) { + shouldSetOutstandingChildRequest = isCurrentUserSubmitter(report); + } else if (isProcessingReport(report)) { + shouldSetOutstandingChildRequest = report.managerID === currentUserAccountID; + } + } + // 2. If this is a thread, we have to mark the parent report preview action as deleted to properly update the UI if (report.parentReportID && report.parentReportActionID) { const oldWorkspaceChatReportID = report.parentReportID; @@ -5909,8 +5919,11 @@ function buildOptimisticChangePolicyData( optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${newPolicyExpenseChatReportID}`, - value: {[optimisticReportPreviewAction.reportActionID]: optimisticReportPreviewAction}, + key: `${ONYXKEYS.COLLECTION.REPORT}${newPolicyExpenseChatReportID}`, + value: { + lastVisibleActionCreated: optimisticReportPreviewAction?.created, + ...(shouldSetOutstandingChildRequest ? {hasOutstandingChildRequest: true} : {}), + }, }); successData.push({ onyxMethod: Onyx.METHOD.MERGE, @@ -5924,8 +5937,8 @@ function buildOptimisticChangePolicyData( }); failureData.push({ onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${newPolicyExpenseChatReportID}`, - value: {[optimisticReportPreviewAction.reportActionID]: null}, + key: `${ONYXKEYS.COLLECTION.REPORT}${newPolicyExpenseChatReportID}`, + value: {lastVisibleActionCreated: policyExpenseChat?.lastVisibleActionCreated, hasOutstandingChildRequest: policyExpenseChat?.hasOutstandingChildRequest}, }); // Set the new report preview action as a parent of the moved report, From a81a8ea3f9fea7f5716c3b2f968f187b75f019fe Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 14 Oct 2025 17:26:01 +0700 Subject: [PATCH 2/2] change correct place --- src/libs/actions/Report.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 4d9a4a2e2891..ec33a86f1bd3 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -5877,11 +5877,8 @@ function buildOptimisticChangePolicyData( optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${newPolicyExpenseChatReportID}`, - value: { - lastVisibleActionCreated: optimisticReportPreviewAction?.created, - ...(shouldSetOutstandingChildRequest ? {hasOutstandingChildRequest: true} : {}), - }, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${newPolicyExpenseChatReportID}`, + value: {[optimisticReportPreviewAction.reportActionID]: optimisticReportPreviewAction}, }); successData.push({ onyxMethod: Onyx.METHOD.MERGE, @@ -5895,8 +5892,8 @@ function buildOptimisticChangePolicyData( }); failureData.push({ onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${newPolicyExpenseChatReportID}`, - value: {lastVisibleActionCreated: policyExpenseChat?.lastVisibleActionCreated, hasOutstandingChildRequest: policyExpenseChat?.hasOutstandingChildRequest}, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${newPolicyExpenseChatReportID}`, + value: {[optimisticReportPreviewAction.reportActionID]: null}, }); // Set the new report preview action as a parent of the moved report, @@ -5916,12 +5913,15 @@ function buildOptimisticChangePolicyData( optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${newPolicyExpenseChatReportID}`, - value: {lastVisibleActionCreated: optimisticReportPreviewAction?.created}, + value: { + lastVisibleActionCreated: optimisticReportPreviewAction?.created, + ...(shouldSetOutstandingChildRequest ? {hasOutstandingChildRequest: true} : {}), + }, }); failureData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${newPolicyExpenseChatReportID}`, - value: {lastVisibleActionCreated: policyExpenseChat?.lastVisibleActionCreated}, + value: {lastVisibleActionCreated: policyExpenseChat?.lastVisibleActionCreated, hasOutstandingChildRequest: policyExpenseChat?.hasOutstandingChildRequest}, }); // 4. Optimistically create a CHANGE_POLICY reportAction on the report using the reportActionID