From b4517f1783efb9f21d98cc1b2d2066da8e1dd970 Mon Sep 17 00:00:00 2001
From: Tsaqif <tsaiinkwa@yahoo.com>
Date: Tue, 30 Jul 2024 09:11:50 +0700
Subject: [PATCH 1/3] Fix UX broken on asssign task from quick action in admins
 announce room

Signed-off-by: Tsaqif <tsaiinkwa@yahoo.com>
---
 src/libs/actions/Policy/Policy.ts                         | 3 +++
 src/libs/actions/Task.ts                                  | 8 ++++++++
 .../SidebarScreen/FloatingActionButtonAndPopover.tsx      | 5 +----
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts
index 1bce525e22bf..45bdd30308d0 100644
--- a/src/libs/actions/Policy/Policy.ts
+++ b/src/libs/actions/Policy/Policy.ts
@@ -1650,6 +1650,7 @@ function buildPolicyData(policyOwnerEmail = '', makeMeAdmin = false, policyName
                     addWorkspaceRoom: null,
                 },
                 pendingAction: null,
+                isOptimisticReport: false,
             },
         },
         {
@@ -1670,6 +1671,7 @@ function buildPolicyData(policyOwnerEmail = '', makeMeAdmin = false, policyName
                 },
                 pendingAction: null,
                 pendingChatMembers: [],
+                isOptimisticReport: false,
             },
         },
         {
@@ -1689,6 +1691,7 @@ function buildPolicyData(policyOwnerEmail = '', makeMeAdmin = false, policyName
                     addWorkspaceRoom: null,
                 },
                 pendingAction: null,
+                isOptimisticReport: false,
             },
         },
         {
diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts
index c4e1e5de81df..3c516f3c8ce4 100644
--- a/src/libs/actions/Task.ts
+++ b/src/libs/actions/Task.ts
@@ -832,6 +832,13 @@ function clearOutTaskInfoAndNavigate(reportID?: string, chatReport?: OnyxEntry<O
     Navigation.navigate(ROUTES.NEW_TASK_DETAILS);
 }
 
+/**
+ * Start out create task action quick action step
+ */
+function startOutCreateTaskQuickAction(reportID: string, targetAccountID: number) {
+    clearOutTaskInfoAndNavigate(reportID, undefined, targetAccountID, true);
+}
+
 /**
  * Get the assignee data
  */
@@ -1149,6 +1156,7 @@ export {
     reopenTask,
     completeTask,
     clearOutTaskInfoAndNavigate,
+    startOutCreateTaskQuickAction,
     getAssignee,
     getShareDestination,
     deleteTask,
diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx
index b96252f4fd95..317611bcb37b 100644
--- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx
+++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx
@@ -267,10 +267,7 @@ function FloatingActionButtonAndPopover(
                 selectOption(() => IOU.startMoneyRequest(CONST.IOU.TYPE.PAY, quickActionReportID, CONST.IOU.REQUEST_TYPE.MANUAL, true), false);
                 return;
             case CONST.QUICK_ACTIONS.ASSIGN_TASK:
-                selectOption(
-                    () => Task.clearOutTaskInfoAndNavigate(isValidReport ? quickActionReportID : '', isValidReport ? quickActionReport : undefined, quickAction.targetAccountID ?? -1, true),
-                    false,
-                );
+                selectOption(() => Task.startOutCreateTaskQuickAction(isValidReport ? quickActionReportID : '', quickAction.targetAccountID ?? -1), false);
                 break;
             case CONST.QUICK_ACTIONS.TRACK_MANUAL:
                 selectOption(() => IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK, quickActionReportID, CONST.IOU.REQUEST_TYPE.MANUAL, true), false);

From dc44e0fcc3270b959eb9c1aec3e929ee8c42fd29 Mon Sep 17 00:00:00 2001
From: Tsaqif <tsaiinkwa@yahoo.com>
Date: Fri, 9 Aug 2024 20:31:27 +0700
Subject: [PATCH 2/3] Add comment

Signed-off-by: Tsaqif <tsaiinkwa@yahoo.com>
---
 src/libs/actions/Task.ts | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts
index fba4a40af356..4e5c96d5e9a3 100644
--- a/src/libs/actions/Task.ts
+++ b/src/libs/actions/Task.ts
@@ -798,6 +798,7 @@ function setAssigneeValue(
         if (!shareToReportID && !skipShareDestination) {
             setShareDestinationValue(report?.reportID ?? '-1');
         }
+        j;
     }
 
     // This is only needed for creation of a new task and so it should only be stored locally
@@ -836,6 +837,10 @@ function clearOutTaskInfoAndNavigate(reportID?: string, chatReport?: OnyxEntry<O
  * Start out create task action quick action step
  */
 function startOutCreateTaskQuickAction(reportID: string, targetAccountID: number) {
+    // The second parameter of clearOutTaskInfoAndNavigate is the chat report or DM report
+    // between the user and the person to whom the task is assigned.
+    // Since chatReportID isn't stored in NVP_QUICK_ACTION_GLOBAL_CREATE, we set
+    // it to undefined. This will make setAssigneeValue to search for the correct report.
     clearOutTaskInfoAndNavigate(reportID, undefined, targetAccountID, true);
 }
 

From eb61f33430ee49bb5c47a9c8e77f058df73dcdec Mon Sep 17 00:00:00 2001
From: Tsaqif <tsaiinkwa@yahoo.com>
Date: Fri, 9 Aug 2024 20:41:52 +0700
Subject: [PATCH 3/3] Fix typo

Signed-off-by: Tsaqif <tsaiinkwa@yahoo.com>
---
 src/libs/actions/Task.ts | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts
index 4e5c96d5e9a3..2333e35fb7e7 100644
--- a/src/libs/actions/Task.ts
+++ b/src/libs/actions/Task.ts
@@ -798,7 +798,6 @@ function setAssigneeValue(
         if (!shareToReportID && !skipShareDestination) {
             setShareDestinationValue(report?.reportID ?? '-1');
         }
-        j;
     }
 
     // This is only needed for creation of a new task and so it should only be stored locally
