From bb5d18ba17a845cbec339000632765732ee2e8a0 Mon Sep 17 00:00:00 2001
From: Chirag Chandrakant Salian <chirag@expensify.com>
Date: Thu, 24 Apr 2025 10:26:12 -0700
Subject: [PATCH] Revert "Removing switchToOldDotOnNonMicroCompanySize"

---
 .../SwitchToOldDotOnCompanySizeParams.ts      |  7 +++++
 src/libs/API/parameters/index.ts              |  1 +
 src/libs/API/types.ts                         |  2 ++
 src/libs/actions/Welcome/index.ts             |  2 ++
 .../index.desktop.ts                          |  6 ++++
 .../index.ts                                  | 29 +++++++++++++++++++
 .../types.ts                                  |  5 ++++
 .../BaseOnboardingAccounting.tsx              |  4 ++-
 8 files changed, 55 insertions(+), 1 deletion(-)
 create mode 100644 src/libs/API/parameters/SwitchToOldDotOnCompanySizeParams.ts
 create mode 100644 src/libs/actions/Welcome/switchToOldDotOnNonMicroCompanySize/index.desktop.ts
 create mode 100644 src/libs/actions/Welcome/switchToOldDotOnNonMicroCompanySize/index.ts
 create mode 100644 src/libs/actions/Welcome/switchToOldDotOnNonMicroCompanySize/types.ts

diff --git a/src/libs/API/parameters/SwitchToOldDotOnCompanySizeParams.ts b/src/libs/API/parameters/SwitchToOldDotOnCompanySizeParams.ts
new file mode 100644
index 000000000000..540dbb5f4ead
--- /dev/null
+++ b/src/libs/API/parameters/SwitchToOldDotOnCompanySizeParams.ts
@@ -0,0 +1,7 @@
+import type {OnboardingCompanySize} from '@src/CONST';
+
+type SwitchToOldDotOnCompanySizeParams = {
+    onboardingCompanySize: OnboardingCompanySize;
+};
+
+export default SwitchToOldDotOnCompanySizeParams;
diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts
index fa9296ca9740..95cf263f5546 100644
--- a/src/libs/API/parameters/index.ts
+++ b/src/libs/API/parameters/index.ts
@@ -187,6 +187,7 @@ export type {default as SetPolicyRequiresTag} from './SetPolicyRequiresTag';
 export type {default as SetPolicyTagsRequired} from './SetPolicyTagsRequired';
 export type {default as RenamePolicyTaglistParams} from './RenamePolicyTaglistParams';
 export type {default as SwitchToOldDotParams} from './SwitchToOldDotParams';
+export type {default as SwitchToOldDotOnCompanySizeParams} from './SwitchToOldDotOnCompanySizeParams';
 export type {default as TrackExpenseParams} from './TrackExpenseParams';
 export type {default as EnablePolicyCategoriesParams} from './EnablePolicyCategoriesParams';
 export type {default as EnablePolicyConnectionsParams} from './EnablePolicyConnectionsParams';
diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts
index 192a74e03e4b..16b0640f79eb 100644
--- a/src/libs/API/types.ts
+++ b/src/libs/API/types.ts
@@ -218,6 +218,7 @@ const WRITE_COMMANDS = {
     CANCEL_PAYMENT: 'CancelPayment',
     ACCEPT_ACH_CONTRACT_FOR_BANK_ACCOUNT: 'AcceptACHContractForBankAccount',
     SWITCH_TO_OLD_DOT: 'SwitchToOldDot',
+    SWITCH_TO_OLD_DOT_ON_COMPANY_SIZE: 'SwitchToOldDotOnCompanySize',
     TRACK_EXPENSE: 'TrackExpense',
     ENABLE_POLICY_CATEGORIES: 'EnablePolicyCategories',
     ENABLE_POLICY_CONNECTIONS: 'EnablePolicyConnections',
@@ -691,6 +692,7 @@ type WriteCommandParameters = {
     [WRITE_COMMANDS.ENABLE_POLICY_DEFAULT_REPORT_TITLE]: Parameters.EnablePolicyDefaultReportTitleParams;
     [WRITE_COMMANDS.SET_WORKSPACE_DEFAULT_SPEND_CATEGORY]: Parameters.SetWorkspaceDefaultSpendCategoryParams;
     [WRITE_COMMANDS.SWITCH_TO_OLD_DOT]: Parameters.SwitchToOldDotParams;
+    [WRITE_COMMANDS.SWITCH_TO_OLD_DOT_ON_COMPANY_SIZE]: Parameters.SwitchToOldDotOnCompanySizeParams;
     [WRITE_COMMANDS.TRACK_EXPENSE]: Parameters.TrackExpenseParams;
     [WRITE_COMMANDS.ENABLE_POLICY_CATEGORIES]: Parameters.EnablePolicyCategoriesParams;
     [WRITE_COMMANDS.ENABLE_POLICY_CONNECTIONS]: Parameters.EnablePolicyConnectionsParams;
diff --git a/src/libs/actions/Welcome/index.ts b/src/libs/actions/Welcome/index.ts
index 23a0f7ee6c9e..4ba55759840f 100644
--- a/src/libs/actions/Welcome/index.ts
+++ b/src/libs/actions/Welcome/index.ts
@@ -15,6 +15,7 @@ import type Onboarding from '@src/types/onyx/Onboarding';
 import type TryNewDot from '@src/types/onyx/TryNewDot';
 import {isEmptyObject} from '@src/types/utils/EmptyObject';
 import {clearInitialPath} from './OnboardingFlow';
+import switchToOldDotOnNonMicroCompanySize from './switchToOldDotOnNonMicroCompanySize';
 
 type OnboardingData = Onboarding | undefined;
 
@@ -245,6 +246,7 @@ export {
     setOnboardingAdminsChatReportID,
     setOnboardingPolicyID,
     completeHybridAppOnboarding,
+    switchToOldDotOnNonMicroCompanySize,
     setOnboardingErrorMessage,
     setOnboardingCompanySize,
     setSelfTourViewed,
diff --git a/src/libs/actions/Welcome/switchToOldDotOnNonMicroCompanySize/index.desktop.ts b/src/libs/actions/Welcome/switchToOldDotOnNonMicroCompanySize/index.desktop.ts
new file mode 100644
index 000000000000..a2bdc5b00c38
--- /dev/null
+++ b/src/libs/actions/Welcome/switchToOldDotOnNonMicroCompanySize/index.desktop.ts
@@ -0,0 +1,6 @@
+import type SwitchToOldDotOnNonMicroCompanySize from './types';
+
+// We don't want to use this API on desktop, so we just noop here
+const switchToOldDotOnNonMicroCompanySize: SwitchToOldDotOnNonMicroCompanySize = () => {};
+
+export default switchToOldDotOnNonMicroCompanySize;
diff --git a/src/libs/actions/Welcome/switchToOldDotOnNonMicroCompanySize/index.ts b/src/libs/actions/Welcome/switchToOldDotOnNonMicroCompanySize/index.ts
new file mode 100644
index 000000000000..3c6a943b502b
--- /dev/null
+++ b/src/libs/actions/Welcome/switchToOldDotOnNonMicroCompanySize/index.ts
@@ -0,0 +1,29 @@
+import type {OnyxUpdate} from 'react-native-onyx';
+import Onyx from 'react-native-onyx';
+import * as API from '@libs/API';
+import {WRITE_COMMANDS} from '@libs/API/types';
+import CONST from '@src/CONST';
+import ONYXKEYS from '@src/ONYXKEYS';
+import type SwitchToOldDotOnNonMicroCompanySize from './types';
+
+const switchToOldDotOnNonMicroCompanySize: SwitchToOldDotOnNonMicroCompanySize = (onboardingCompanySize) => {
+    if (onboardingCompanySize === CONST.ONBOARDING_COMPANY_SIZE.MICRO) {
+        return;
+    }
+
+    const optimisticData: OnyxUpdate[] = [
+        {
+            onyxMethod: Onyx.METHOD.MERGE,
+            key: ONYXKEYS.NVP_TRYNEWDOT,
+            value: {
+                classicRedirect: {
+                    dismissed: true,
+                },
+            },
+        },
+    ];
+
+    API.write(WRITE_COMMANDS.SWITCH_TO_OLD_DOT_ON_COMPANY_SIZE, {onboardingCompanySize}, {optimisticData});
+};
+
+export default switchToOldDotOnNonMicroCompanySize;
diff --git a/src/libs/actions/Welcome/switchToOldDotOnNonMicroCompanySize/types.ts b/src/libs/actions/Welcome/switchToOldDotOnNonMicroCompanySize/types.ts
new file mode 100644
index 000000000000..aa888445eaaf
--- /dev/null
+++ b/src/libs/actions/Welcome/switchToOldDotOnNonMicroCompanySize/types.ts
@@ -0,0 +1,5 @@
+import type {OnboardingCompanySize} from '@src/CONST';
+
+type SwitchToOldDotOnNonMicroCompanySize = (onboardingCompanySize: OnboardingCompanySize) => void;
+
+export default SwitchToOldDotOnNonMicroCompanySize;
diff --git a/src/pages/OnboardingAccounting/BaseOnboardingAccounting.tsx b/src/pages/OnboardingAccounting/BaseOnboardingAccounting.tsx
index 2f957fb952d8..d0d950a65038 100644
--- a/src/pages/OnboardingAccounting/BaseOnboardingAccounting.tsx
+++ b/src/pages/OnboardingAccounting/BaseOnboardingAccounting.tsx
@@ -25,7 +25,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
 import {openOldDotLink} from '@libs/actions/Link';
 import {createWorkspace, generatePolicyID} from '@libs/actions/Policy/Policy';
 import {completeOnboarding} from '@libs/actions/Report';
-import {setOnboardingAdminsChatReportID, setOnboardingPolicyID} from '@libs/actions/Welcome';
+import {setOnboardingAdminsChatReportID, setOnboardingPolicyID, switchToOldDotOnNonMicroCompanySize} from '@libs/actions/Welcome';
 import getPlatform from '@libs/getPlatform';
 import navigateAfterOnboarding from '@libs/navigateAfterOnboarding';
 import Navigation from '@libs/Navigation/Navigation';
@@ -178,6 +178,8 @@ function BaseOnboardingAccounting({shouldUseNativeStyles}: BaseOnboardingAccount
                         return;
                     }
 
+                    switchToOldDotOnNonMicroCompanySize(onboardingCompanySize);
+
                     const shouldCreateWorkspace = !onboardingPolicyID && !paidGroupPolicy;
 
                     // We need `adminsChatReportID` for `completeOnboarding`, but at the same time, we don't want to call `createWorkspace` more than once.
