Skip to content

Commit

Permalink
Merge pull request #50617 from bernhardoj/fix/50311-blank-qab-when-cl…
Browse files Browse the repository at this point in the history
…ear-report-error

Revert QAB when the action fails
  • Loading branch information
rlinoz authored Oct 14, 2024
2 parents 1535588 + 3a1d1a8 commit f7fce02
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
44 changes: 32 additions & 12 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,18 +633,6 @@ function buildOnyxDataForMoneyRequest(
});
}

if (!isOneOnOneSplit) {
optimisticData.push({
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
value: {
action: newQuickAction,
chatReportID: chatReport?.reportID,
isFirstQuickAction: isEmptyObject(quickAction),
},
});
}

if (optimisticPolicyRecentlyUsedCategories.length) {
optimisticData.push({
onyxMethod: Onyx.METHOD.SET,
Expand Down Expand Up @@ -875,6 +863,23 @@ function buildOnyxDataForMoneyRequest(
},
];

if (!isOneOnOneSplit) {
optimisticData.push({
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
value: {
action: newQuickAction,
chatReportID: chatReport?.reportID,
isFirstQuickAction: isEmptyObject(quickAction),
},
});
failureData.push({
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
value: quickAction ?? null,
});
}

if (!isEmptyObject(transactionThreadCreatedReportAction)) {
failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
Expand Down Expand Up @@ -4103,6 +4108,11 @@ function createSplitsAndOnyxData(
pendingFields: null,
},
},
{
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
value: quickAction ?? null,
},
];

if (existingSplitChatReport) {
Expand Down Expand Up @@ -4673,6 +4683,11 @@ function startSplitBill({
errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('iou.error.genericCreateFailureMessage'),
},
},
{
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
value: quickAction ?? null,
},
];

if (existingSplitChatReport) {
Expand Down Expand Up @@ -6353,6 +6368,11 @@ function getSendMoneyParams(
},
},
},
{
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
value: quickAction ?? null,
},
];

// Now, let's add the data we need just when we are creating a new chat report
Expand Down
5 changes: 5 additions & 0 deletions src/libs/actions/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ function createTaskAndNavigate(
targetAccountID: assigneeAccountID,
},
});
failureData.push({
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
value: quickAction ?? null,
});

// If needed, update optimistic data for parent report action of the parent report.
const optimisticParentReportData = ReportUtils.getOptimisticDataForParentReportAction(parentReportID, currentTime, CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD);
Expand Down

0 comments on commit f7fce02

Please sign in to comment.