From abb5ce3d8271666fb4b0e017554a5e903a82f5d9 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 28 Mar 2024 15:32:55 +0700 Subject: [PATCH 1/3] Fix created action is duplicate when assigning a task --- src/libs/actions/Task.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 690d62f02f48..4864fc5c3b63 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -680,7 +680,13 @@ function setAssigneeValue(assigneeEmail: string, assigneeAccountID: number, shar Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[assigneeAccountID]: optimisticPersonalDetailsListAction}); } - setAssigneeChatReport(chatReport); + setAssigneeChatReport({ + ...chatReport, + isOptimisticReport: chatReport?.isOptimisticReport, + pendingFields: chatReport?.pendingFields, + pendingAction: chatReport?.pendingAction, + errorFields: chatReport?.errorFields, + }); // If there is no share destination set, automatically set it to the assignee chat report // This allows for a much quicker process when creating a new task and is likely the desired share destination most times From 14dbcd1edc6fcdf0a5eedd676e25bcdd8467fb6f Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 28 Mar 2024 16:19:50 +0700 Subject: [PATCH 2/3] fallback isOptimisticReport --- src/libs/actions/Task.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 4864fc5c3b63..56bef2dad660 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -682,10 +682,9 @@ function setAssigneeValue(assigneeEmail: string, assigneeAccountID: number, shar setAssigneeChatReport({ ...chatReport, - isOptimisticReport: chatReport?.isOptimisticReport, + isOptimisticReport: chatReport?.isOptimisticReport ?? false, pendingFields: chatReport?.pendingFields, pendingAction: chatReport?.pendingAction, - errorFields: chatReport?.errorFields, }); // If there is no share destination set, automatically set it to the assignee chat report From d8abbe231a795120753457c3cd192f8c7a84cf44 Mon Sep 17 00:00:00 2001 From: nkdengineer <161821005+nkdengineer@users.noreply.github.com> Date: Fri, 29 Mar 2024 18:12:21 +0700 Subject: [PATCH 3/3] Update src/libs/actions/Task.ts Co-authored-by: Hans --- src/libs/actions/Task.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 62a4a5f6a686..bb80bc767cb3 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -690,7 +690,7 @@ function setAssigneeValue( } // The optimistic field may not exist in the existing report and it can be overridden by the optimistic field of previous report data when merging the assignee chat report - // So we should add these optimistic fields here to prevent merging incorrectly which can lead to creating duplicate created actions for an existing report + // Therefore, we should add these optimistic fields here to prevent incorrect merging, which could lead to the creation of duplicate actions for an existing report setAssigneeChatReport({ ...report, isOptimisticReport: report?.isOptimisticReport ?? false,