From 5ba7e362b448f00eba49e8dfda1d5e6e732e056a Mon Sep 17 00:00:00 2001 From: mkzie2 Date: Mon, 18 Nov 2024 13:32:43 +0700 Subject: [PATCH 1/2] update childStateNum and childStatusNum for parent report action --- src/libs/actions/IOU.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 3b0b43accbc6..30ff1ccf7a78 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -7065,6 +7065,19 @@ function unapproveExpenseReport(expenseReport: OnyxEntry) { const optimisticData: OnyxUpdate[] = [optimisticIOUReportData, optimisticReportActionData, optimisticNextStepData]; + if (expenseReport.parentReportID && expenseReport.parentReportActionID) { + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.parentReportID}`, + value: { + [expenseReport.parentReportActionID]: { + childStateNum: CONST.REPORT.STATE_NUM.SUBMITTED, + childStatusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, + }, + }, + }); + } + const successData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, @@ -7276,6 +7289,19 @@ function cancelPayment(expenseReport: OnyxEntry, chatReport: O }, ]; + if (expenseReport.parentReportID && expenseReport.parentReportActionID) { + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.parentReportID}`, + value: { + [expenseReport.parentReportActionID]: { + childStateNum: stateNum, + childStatusNum: statusNum, + }, + }, + }); + } + optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${expenseReport.reportID}`, From e30f72e98a1768ab7406b8e16c5cafc96c74e9fa Mon Sep 17 00:00:00 2001 From: mkzie2 Date: Tue, 19 Nov 2024 21:29:01 +0700 Subject: [PATCH 2/2] add failureData --- src/libs/actions/IOU.ts | 74 ++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 4d487fa14aaa..64c2eb02269b 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -7083,19 +7083,6 @@ function unapproveExpenseReport(expenseReport: OnyxEntry) { const optimisticData: OnyxUpdate[] = [optimisticIOUReportData, optimisticReportActionData, optimisticNextStepData]; - if (expenseReport.parentReportID && expenseReport.parentReportActionID) { - optimisticData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.parentReportID}`, - value: { - [expenseReport.parentReportActionID]: { - childStateNum: CONST.REPORT.STATE_NUM.SUBMITTED, - childStatusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, - }, - }, - }); - } - const successData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, @@ -7134,6 +7121,30 @@ function unapproveExpenseReport(expenseReport: OnyxEntry) { }, ]; + if (expenseReport.parentReportID && expenseReport.parentReportActionID) { + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.parentReportID}`, + value: { + [expenseReport.parentReportActionID]: { + childStateNum: CONST.REPORT.STATE_NUM.SUBMITTED, + childStatusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, + }, + }, + }); + + failureData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.parentReportID}`, + value: { + [expenseReport.parentReportActionID]: { + childStateNum: expenseReport.stateNum, + childStatusNum: expenseReport.statusNum, + }, + }, + }); + } + const parameters: UnapproveExpenseReportParams = { reportID: expenseReport.reportID, reportActionID: optimisticUnapprovedReportAction.reportActionID, @@ -7307,19 +7318,6 @@ function cancelPayment(expenseReport: OnyxEntry, chatReport: O }, ]; - if (expenseReport.parentReportID && expenseReport.parentReportActionID) { - optimisticData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.parentReportID}`, - value: { - [expenseReport.parentReportActionID]: { - childStateNum: stateNum, - childStatusNum: statusNum, - }, - }, - }); - } - optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${expenseReport.reportID}`, @@ -7357,6 +7355,30 @@ function cancelPayment(expenseReport: OnyxEntry, chatReport: O }, ]; + if (expenseReport.parentReportID && expenseReport.parentReportActionID) { + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.parentReportID}`, + value: { + [expenseReport.parentReportActionID]: { + childStateNum: stateNum, + childStatusNum: statusNum, + }, + }, + }); + + failureData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.parentReportID}`, + value: { + [expenseReport.parentReportActionID]: { + childStateNum: expenseReport.stateNum, + childStatusNum: expenseReport.statusNum, + }, + }, + }); + } + if (chatReport?.reportID) { failureData.push({ onyxMethod: Onyx.METHOD.MERGE,