From 4fd366e526ee6591f715afe44cd141e0b7b99b6b Mon Sep 17 00:00:00 2001
From: huutech <20178761+huult@users.noreply.github.com>
Date: Sat, 1 Nov 2025 08:35:19 +0700
Subject: [PATCH 1/5] fix back button redirects to Upgrade after workspace
 creation

---
 src/pages/iou/request/step/IOURequestStepUpgrade.tsx | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/pages/iou/request/step/IOURequestStepUpgrade.tsx b/src/pages/iou/request/step/IOURequestStepUpgrade.tsx
index a281f1fdfd88..012ea8737d41 100644
--- a/src/pages/iou/request/step/IOURequestStepUpgrade.tsx
+++ b/src/pages/iou/request/step/IOURequestStepUpgrade.tsx
@@ -83,14 +83,16 @@ function IOURequestStepUpgrade({
                 // Let the confirmation step decide the distance rate because policy data is not fully available at this step
                 setCustomUnitRateID(transactionID, '-1');
                 Navigation.setParams({reportID: expenseReportID});
-                Navigation.navigate(ROUTES.WORKSPACE_CREATE_DISTANCE_RATE.getRoute(policyID, transactionID, expenseReportID));
+                Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.navigate(ROUTES.WORKSPACE_CREATE_DISTANCE_RATE.getRoute(policyID, transactionID, expenseReportID)));
                 break;
             }
             case CONST.UPGRADE_PATHS.REPORTS:
-                Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_REPORT.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, reportID));
+                Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_REPORT.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, reportID)));
                 break;
             case CONST.UPGRADE_PATHS.CATEGORIES:
-                Navigation.navigate(backTo ?? ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, reportID));
+                Navigation.setNavigationActionToMicrotaskQueue(() =>
+                    Navigation.navigate(backTo ?? ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, reportID)),
+                );
                 break;
             default:
         }

From 5a37d09a0ef61771199fa181be3e94cdf422b456 Mon Sep 17 00:00:00 2001
From: huutech <20178761+huult@users.noreply.github.com>
Date: Sat, 1 Nov 2025 12:13:16 +0700
Subject: [PATCH 2/5] update use microtask queue only on web platform

---
 .../request/step/IOURequestStepUpgrade.tsx    | 24 ++++++++++++++-----
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/pages/iou/request/step/IOURequestStepUpgrade.tsx b/src/pages/iou/request/step/IOURequestStepUpgrade.tsx
index 012ea8737d41..2db25d090865 100644
--- a/src/pages/iou/request/step/IOURequestStepUpgrade.tsx
+++ b/src/pages/iou/request/step/IOURequestStepUpgrade.tsx
@@ -12,6 +12,7 @@ import useOnyx from '@hooks/useOnyx';
 import useThemeStyles from '@hooks/useThemeStyles';
 import {setTransactionReport} from '@libs/actions/Transaction';
 import type CreateWorkspaceParams from '@libs/API/parameters/CreateWorkspaceParams';
+import getPlatform from '@libs/getPlatform';
 import Navigation from '@libs/Navigation/Navigation';
 import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
 import type {MoneyRequestNavigatorParamList} from '@libs/Navigation/types';
@@ -22,7 +23,7 @@ import {setCustomUnitRateID, setMoneyRequestParticipants} from '@userActions/IOU
 import CONST from '@src/CONST';
 import * as Policy from '@src/libs/actions/Policy/Policy';
 import ONYXKEYS from '@src/ONYXKEYS';
-import ROUTES from '@src/ROUTES';
+import ROUTES, {Route} from '@src/ROUTES';
 import type SCREENS from '@src/SCREENS';
 
 type IOURequestStepUpgradeProps = PlatformStackScreenProps<MoneyRequestNavigatorParamList, typeof SCREENS.MONEY_REQUEST.STEP_UPGRADE>;
@@ -48,6 +49,8 @@ function IOURequestStepUpgrade({
     const isDistanceRateUpgrade = upgradePath === CONST.UPGRADE_PATHS.DISTANCE_RATES;
     const isCategorizing = upgradePath === CONST.UPGRADE_PATHS.CATEGORIES;
     const isReporting = upgradePath === CONST.UPGRADE_PATHS.REPORTS;
+    const platform = getPlatform();
+    const isWebOrDesktop = platform === CONST.PLATFORM.WEB || platform === CONST.PLATFORM.DESKTOP;
 
     const feature = useMemo(
         () =>
@@ -57,6 +60,14 @@ function IOURequestStepUpgrade({
         [upgradePath],
     );
 
+    const navigateWithMicrotask = (route: Route) => {
+        if (true) {
+            Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.navigate(route));
+        } else {
+            Navigation.navigate(route);
+        }
+    };
+
     const afterUpgradeAcknowledged = useCallback(() => {
         const expenseReportID = policyDataRef.current?.expenseChatReportID ?? reportID;
         const policyID = policyDataRef.current?.policyID;
@@ -83,16 +94,17 @@ function IOURequestStepUpgrade({
                 // Let the confirmation step decide the distance rate because policy data is not fully available at this step
                 setCustomUnitRateID(transactionID, '-1');
                 Navigation.setParams({reportID: expenseReportID});
-                Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.navigate(ROUTES.WORKSPACE_CREATE_DISTANCE_RATE.getRoute(policyID, transactionID, expenseReportID)));
+
+                navigateWithMicrotask(ROUTES.WORKSPACE_CREATE_DISTANCE_RATE.getRoute(policyID, transactionID, expenseReportID));
                 break;
             }
             case CONST.UPGRADE_PATHS.REPORTS:
-                Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_REPORT.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, reportID)));
+                navigateWithMicrotask(ROUTES.MONEY_REQUEST_STEP_REPORT.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, reportID));
+
                 break;
             case CONST.UPGRADE_PATHS.CATEGORIES:
-                Navigation.setNavigationActionToMicrotaskQueue(() =>
-                    Navigation.navigate(backTo ?? ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, reportID)),
-                );
+                navigateWithMicrotask(backTo ?? ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, reportID));
+
                 break;
             default:
         }

From 7b74b6488dd7c49a4e1f1e8eddb51e178ec6ef51 Mon Sep 17 00:00:00 2001
From: huutech <20178761+huult@users.noreply.github.com>
Date: Sat, 1 Nov 2025 12:14:02 +0700
Subject: [PATCH 3/5] update import type

---
 src/pages/iou/request/step/IOURequestStepUpgrade.tsx | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/pages/iou/request/step/IOURequestStepUpgrade.tsx b/src/pages/iou/request/step/IOURequestStepUpgrade.tsx
index 2db25d090865..81962bc4bec8 100644
--- a/src/pages/iou/request/step/IOURequestStepUpgrade.tsx
+++ b/src/pages/iou/request/step/IOURequestStepUpgrade.tsx
@@ -23,7 +23,8 @@ import {setCustomUnitRateID, setMoneyRequestParticipants} from '@userActions/IOU
 import CONST from '@src/CONST';
 import * as Policy from '@src/libs/actions/Policy/Policy';
 import ONYXKEYS from '@src/ONYXKEYS';
-import ROUTES, {Route} from '@src/ROUTES';
+import type {Route} from '@src/ROUTES';
+import ROUTES from '@src/ROUTES';
 import type SCREENS from '@src/SCREENS';
 
 type IOURequestStepUpgradeProps = PlatformStackScreenProps<MoneyRequestNavigatorParamList, typeof SCREENS.MONEY_REQUEST.STEP_UPGRADE>;
@@ -61,7 +62,7 @@ function IOURequestStepUpgrade({
     );
 
     const navigateWithMicrotask = (route: Route) => {
-        if (true) {
+        if (isWebOrDesktop) {
             Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.navigate(route));
         } else {
             Navigation.navigate(route);

From a0824dc6659ab8e3b8c19756f290748fa585270f Mon Sep 17 00:00:00 2001
From: huutech <20178761+huult@users.noreply.github.com>
Date: Sat, 1 Nov 2025 12:15:54 +0700
Subject: [PATCH 4/5] update dependencies

---
 src/pages/iou/request/step/IOURequestStepUpgrade.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pages/iou/request/step/IOURequestStepUpgrade.tsx b/src/pages/iou/request/step/IOURequestStepUpgrade.tsx
index 81962bc4bec8..27f2c32a6d34 100644
--- a/src/pages/iou/request/step/IOURequestStepUpgrade.tsx
+++ b/src/pages/iou/request/step/IOURequestStepUpgrade.tsx
@@ -109,7 +109,7 @@ function IOURequestStepUpgrade({
                 break;
             default:
         }
-    }, [action, backTo, reportID, shouldSubmitExpense, transactionID, upgradePath]);
+    }, [action, backTo, navigateWithMicrotask, reportID, shouldSubmitExpense, transactionID, upgradePath]);
 
     const adminParticipant = useMemo(() => {
         const participant = transaction?.participants?.[0];

From c141f8441de8a1d61f932d2a23a2128cfcccd72c Mon Sep 17 00:00:00 2001
From: huutech <20178761+huult@users.noreply.github.com>
Date: Wed, 5 Nov 2025 08:54:08 +0700
Subject: [PATCH 5/5] update lint

---
 .../iou/request/step/IOURequestStepUpgrade.tsx  | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/pages/iou/request/step/IOURequestStepUpgrade.tsx b/src/pages/iou/request/step/IOURequestStepUpgrade.tsx
index 27f2c32a6d34..0e40247046f8 100644
--- a/src/pages/iou/request/step/IOURequestStepUpgrade.tsx
+++ b/src/pages/iou/request/step/IOURequestStepUpgrade.tsx
@@ -61,13 +61,16 @@ function IOURequestStepUpgrade({
         [upgradePath],
     );
 
-    const navigateWithMicrotask = (route: Route) => {
-        if (isWebOrDesktop) {
-            Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.navigate(route));
-        } else {
-            Navigation.navigate(route);
-        }
-    };
+    const navigateWithMicrotask = useCallback(
+        (route: Route) => {
+            if (isWebOrDesktop) {
+                Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.navigate(route));
+            } else {
+                Navigation.navigate(route);
+            }
+        },
+        [isWebOrDesktop],
+    );
 
     const afterUpgradeAcknowledged = useCallback(() => {
         const expenseReportID = policyDataRef.current?.expenseChatReportID ?? reportID;
