Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert QAB when the action fails #50617

Merged
Merged
Show file tree
Hide file tree
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
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
Loading