Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ import {
hasOutstandingChildRequest,
isChatThread as isChatThreadReportUtils,
isConciergeChatReport,
isCurrentUserSubmitter,
isExpenseReport,
isGroupChat as isGroupChatReportUtils,
isHiddenForCurrentUser,
Expand Down Expand Up @@ -5779,6 +5780,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;
Expand Down Expand Up @@ -5903,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
Expand Down