Skip to content

Commit

Permalink
add failureData
Browse files Browse the repository at this point in the history
  • Loading branch information
mkzie2 committed Nov 19, 2024
1 parent 25b0808 commit e30f72e
Showing 1 changed file with 48 additions and 26 deletions.
74 changes: 48 additions & 26 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7083,19 +7083,6 @@ function unapproveExpenseReport(expenseReport: OnyxEntry<OnyxTypes.Report>) {

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,
Expand Down Expand Up @@ -7134,6 +7121,30 @@ function unapproveExpenseReport(expenseReport: OnyxEntry<OnyxTypes.Report>) {
},
];

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,
Expand Down Expand Up @@ -7307,19 +7318,6 @@ function cancelPayment(expenseReport: OnyxEntry<OnyxTypes.Report>, 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}`,
Expand Down Expand Up @@ -7357,6 +7355,30 @@ function cancelPayment(expenseReport: OnyxEntry<OnyxTypes.Report>, 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,
Expand Down

0 comments on commit e30f72e

Please sign in to comment.