Skip to content

Commit

Permalink
Merge pull request #43568 from Expensify/vit-clearOptimisticTask
Browse files Browse the repository at this point in the history
Add successData to the completeGuidedSetup
  • Loading branch information
luacmartins authored Jun 12, 2024
2 parents 6b9f19e + 20621a1 commit 79e619a
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3299,6 +3299,50 @@ function completeOnboarding(
return acc;
}, []);

const tasksForSuccessData = tasksData.reduce<OnyxUpdate[]>((acc, {currentTask, taskCreatedAction, taskReportAction, completedTaskReportAction}) => {
acc.push(
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`,
value: {
[taskReportAction.reportAction.reportActionID]: {pendingAction: null},
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${currentTask.reportID}`,
value: {
pendingFields: {
createChat: null,
reportName: null,
description: null,
managerID: null,
},
isOptimisticReport: false,
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${currentTask.reportID}`,
value: {
[taskCreatedAction.reportActionID]: {pendingAction: null},
},
},
);

if (completedTaskReportAction) {
acc.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${currentTask.reportID}`,
value: {
[completedTaskReportAction.reportActionID]: {pendingAction: null},
},
});
}

return acc;
}, []);

const optimisticData: OnyxUpdate[] = [
...tasksForOptimisticData,
{
Expand All @@ -3323,6 +3367,7 @@ function completeOnboarding(
},
];
const successData: OnyxUpdate[] = [
...tasksForSuccessData,
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`,
Expand Down

0 comments on commit 79e619a

Please sign in to comment.