Repository: Expensify/App
Pull request #60990: fix - Do not use credentials for sending OTP on private domain onboarding flow
Author: login: allroundexperts
Labels: name: Ready To Build
Created: 2025-04-28T22:35:29Z | Merged: 2025-05-20T23:32:19Z

<!-- If necessary, assign reviewers that know the area or changes well. Feel free to tag any additional reviewers you see fit. -->

### Explanation of Change
<!-- Explain what your change does and how it addresses the linked issue -->
This PR fixes the OTP which was not being sent on the hybrid iOS and android app when signing up with a private domain.

### Fixed Issues
<!---
1. Please postfix `$` with a URL link to the GitHub issue this Pull Request is fixing. For example, `$ https://github.com/Expensify/App/issues/<issueID>`.
2. Please postfix  `PROPOSAL:` with a URL link to your GitHub comment, which contains the approved proposal (i.e. the proposal that was approved by Expensify).  For example, `PROPOSAL: https://github.com/Expensify/App/issues/<issueID>#issuecomment-1369752925`

Do NOT add the special GH keywords like `fixed` etc, we have our own process of managing the flow.
It MUST be an entire link to the github issue and your comment proposal ; otherwise, the linking and its automation will not work as expected.

Make sure this section looks similar to this (you can link multiple issues using the same formatting, just add a new line):

$ https://github.com/Expensify/App/issues/<issueID>
$ https://github.com/Expensify/App/issues/<issueID(comment)>

Do NOT only link the issue number like this: $ #<issueID>
--->
$ https://github.com/Expensify/App/issues/48189
PROPOSAL: N/A


<!--- 
If you want to trigger adhoc build of hybrid app from specific Mobile-Expensify PR please link it like this:

MOBILE-EXPENSIFY: https://github.com/Expensify/Mobile-Expensify/pull/<PR-number>

--->

### Tests
<!---
Add a numbered list of manual tests you performed that validates your changes work on all platforms, and that there are no regressions present.
Add any additional test steps if test steps are unique to a particular platform.
Manual test steps should be written so that your reviewer can repeat and verify one or more expected outcomes in the development environment.

For example:
1. Click on the text input to bring it into focus
2. Upload an image via copy paste
3. Verify a modal appears displaying a preview of that image
--->

**Pre-Req**
Enable the `PRIVATE_DOMAIN_ONBOARDING` beta.

**Test 1**
1. Open the App and signup with a private domain.
2. Enter first and last name
3. On the OTP screen, verify that OTP is received in your mailbox.

**Test 2**
1. Open the App and signup with a public domain.
2. Verify that "Add your work email" screen is displayed.


- [x] Verify that no errors appear in the JS console

### Offline tests
<!---
Add any relevant steps that validate your changes work as expected in a variety of network states e.g. "offline", "spotty connection", "slow internet", etc. Manual test steps should be written so that your reviewer and QA testers can repeat and verify one or more expected outcomes. If you are unsure how the behavior should work ask for advice in the `#expensify-open-source` Slack channel.
--->
N/A

### QA Steps
<!---
Add a numbered list of manual tests that can be performed by our QA engineers on the staging environment to validate that your changes work on all platforms, and that there are no regressions present.
Add any additional QA steps if test steps are unique to a particular platform.
Manual test steps should be written so that the QA engineer can repeat and verify one or more expected outcomes in the staging environment.

For example:
1. Click on the text input to bring it into focus
5. Upload an image via copy paste
6. Verify a modal appears displaying a preview of that image

It's acceptable to write "Same as tests" if the QA team is able to run the tests in the above "Tests" section.
--->

Same as above

- [x] Verify that no errors appear in the JS console

### PR Author Checklist
<!--
This is a checklist for PR authors. Please make sure to complete all tasks and check them off once you do, or else your PR will not be merged!
-->

- [x] I linked the correct issue in the `### Fixed Issues` section above
- [x] I wrote clear testing steps that cover the changes made in this PR
    - [x] I added steps for local testing in the `Tests` section
    - [x] I added steps for the expected offline behavior in the `Offline steps` section
    - [x] I added steps for Staging and/or Production testing in the `QA steps` section
    - [x] I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    - [x] I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    - [x] I tested this PR with a [High Traffic account](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md#high-traffic-accounts) against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
- [x] I included screenshots or videos for tests on [all platforms](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md#make-sure-you-can-test-on-all-platforms)
- [x] I ran the tests on **all platforms** & verified they passed on:
    - [x] Android: Native
    - [x] Android: mWeb Chrome
    - [x] iOS: Native
    - [x] iOS: mWeb Safari
    - [x] MacOS: Chrome / Safari
    - [x] MacOS: Desktop
- [x] I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
- [x] I followed proper code patterns (see [Reviewing the code](https://github.com/Expensify/App/blob/main/contributingGuides/PR_REVIEW_GUIDELINES.md#reviewing-the-code))
    - [x] I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. `toggleReport` and not `onIconClick`)
    - [x] I verified that comments were added to code that is not self explanatory
    - [x] I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    - [x] I verified any copy / text shown in the product is localized by adding it to `src/languages/*` files and using the [translation method](https://github.com/Expensify/App/blob/4bd99402cebdf4d7394e0d1f260879ea238197eb/src/components/withLocalize.js#L60)
      - [x] If any non-english text was added/modified, I used [JaimeGPT](https://chatgpt.com/g/g-2dgOQl5VM-english-to-spanish-translator-aka-jaimegpt) to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    - [x] I verified all numbers, amounts, dates and phone numbers shown in the product are using the [localization methods](https://github.com/Expensify/App/blob/4bd99402cebdf4d7394e0d1f260879ea238197eb/src/components/withLocalize.js#L60-L68)
    - [x] I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    - [x] I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    - [x] I verified the JSDocs style guidelines (in [`STYLE.md`](https://github.com/Expensify/App/blob/main/contributingGuides/STYLE.md#jsdocs)) were followed
- [x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
- [x] I followed the guidelines as stated in the [Review Guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/PR_REVIEW_GUIDELINES.md)
- [x] I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like `Avatar`, I verified the components using `Avatar` are working as expected)
- [x] I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
- [x] I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
- [x] I verified that if a function's arguments changed that all usages have also been updated correctly
- [x] If any new file was added I verified that:
    - [x] The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
- [x] If a new CSS style is added I verified that:
    - [x] A similar style doesn't already exist
    - [x] The style can't be created with an existing [StyleUtils](https://github.com/Expensify/App/blob/main/src/styles/utils/index.ts) function (i.e. `StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)`)
- [x] If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
- [x] If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like `Avatar` is modified, I verified that `Avatar` is working as expected in all cases)
- [x] If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
- [x] If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
- [x] If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    - [x] I verified that all the inputs inside a form are aligned with each other.
    - [x] I added `Design` label and/or tagged `@Expensify/design` so the design team can review the changes.
- [x] If a new page is added, I verified it's using the `ScrollView` component to make it scrollable when more elements are added to the page.
- [x] I added [unit tests](https://github.com/Expensify/App/blob/main/tests/README.md) for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
- [x] If the `main` branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the `Test` steps.

### Screenshots/Videos
<details>
<summary>Android: Native</summary>

<!-- add screenshots or videos here -->
Unable to build android 😢 
</details>

<details>
<summary>Android: mWeb Chrome</summary>

<!-- add screenshots or videos here -->
https://github.com/user-attachments/assets/99ea663b-dc7d-4b3e-b0c1-78a05d329803

</details>

<details>
<summary>iOS: Native</summary>

<!-- add screenshots or videos here -->
https://github.com/user-attachments/assets/29328515-ed74-4ad5-8ee1-4076e04638d0

</details>

<details>
<summary>iOS: mWeb Safari</summary>

<!-- add screenshots or videos here -->
https://github.com/user-attachments/assets/01a9f964-f99c-49f4-9314-b4eb4b96d051

</details>

<details>
<summary>MacOS: Chrome / Safari</summary>

<!-- add screenshots or videos here -->
https://github.com/user-attachments/assets/dbc9b0cb-91d0-46fe-93e4-e39e7d7d8675

</details>

<details>
<summary>MacOS: Desktop</summary>

<!-- add screenshots or videos here -->
https://github.com/user-attachments/assets/624a08f1-e512-4f10-bd73-84c65a7dfc60

</details>



Diff:
diff --git a/src/hooks/useOnboardingFlow.ts b/src/hooks/useOnboardingFlow.ts
index 31af3364aa2c..76c5400e9250 100644
--- a/src/hooks/useOnboardingFlow.ts
+++ b/src/hooks/useOnboardingFlow.ts
@@ -10,6 +10,7 @@ import CONFIG from '@src/CONFIG';
 import ONYXKEYS from '@src/ONYXKEYS';
 import ROUTES from '@src/ROUTES';
 import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';
+import usePermissions from './usePermissions';
 
 /**
  * Hook to handle redirection to the onboarding flow based on the user's onboarding status
@@ -33,6 +34,8 @@ function useOnboardingFlowRouter() {
     const [dismissedProductTraining, dismissedProductTrainingMetadata] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {canBeMissing: true});
 
     const [isSingleNewDotEntry, isSingleNewDotEntryMetadata] = useOnyx(ONYXKEYS.IS_SINGLE_NEW_DOT_ENTRY, {canBeMissing: true});
+    const {canUsePrivateDomainOnboarding} = usePermissions();
+
     useEffect(() => {
         // This should delay opening the onboarding modal so it does not interfere with the ongoing ReportScreen params changes
         InteractionManager.runAfterInteractions(() => {
@@ -76,14 +79,24 @@ function useOnboardingFlowRouter() {
                 // This is a special case when user created an account from NewDot without finishing the onboarding flow and then logged in from OldDot
                 if (isHybridAppOnboardingCompleted === true && isOnboardingCompleted === false && !startedOnboardingFlowRef.current) {
                     startedOnboardingFlowRef.current = true;
-                    startOnboardingFlow(undefined, onboardingValues, account?.isFromPublicDomain);
+                    startOnboardingFlow({
+                        canUsePrivateDomainOnboarding,
+                        onboardingValuesParam: onboardingValues,
+                        isUserFromPublicDomain: !!account?.isFromPublicDomain,
+                        hasAccessiblePolicies: !!account?.hasAccessibleDomainPolicies,
+                    });
                 }
             }
 
             // If the user is not transitioning from OldDot to NewDot, we should start NewDot onboarding flow if it's not completed yet
             if (!CONFIG.IS_HYBRID_APP && isOnboardingCompleted === false && !startedOnboardingFlowRef.current) {
                 startedOnboardingFlowRef.current = true;
-                startOnboardingFlow(undefined, onboardingValues, account?.isFromPublicDomain);
+                startOnboardingFlow({
+                    canUsePrivateDomainOnboarding,
+                    onboardingValuesParam: onboardingValues,
+                    isUserFromPublicDomain: !!account?.isFromPublicDomain,
+                    hasAccessiblePolicies: !!account?.hasAccessibleDomainPolicies,
+                });
             }
         });
     }, [
@@ -98,7 +111,9 @@ function useOnboardingFlowRouter() {
         dismissedProductTraining?.migratedUserWelcomeModal,
         onboardingValues,
         dismissedProductTraining,
+        canUsePrivateDomainOnboarding,
         account?.isFromPublicDomain,
+        account?.hasAccessibleDomainPolicies,
     ]);
 
     return {isOnboardingCompleted: hasCompletedGuidedSetupFlowSelector(onboardingValues), isHybridAppOnboardingCompleted};
diff --git a/src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx
index 2ce4f665d739..b34a49b698d8 100644
--- a/src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx
+++ b/src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx
@@ -2,6 +2,7 @@ import {CardStyleInterpolators} from '@react-navigation/stack';
 import React, {useCallback, useEffect} from 'react';
 import {View} from 'react-native';
 import {useOnyx} from 'react-native-onyx';
+import type {ValueOf} from 'type-fest';
 import NoDropZone from '@components/DragAndDrop/NoDropZone';
 import FocusTrapForScreens from '@components/FocusTrap/FocusTrapForScreen';
 import useKeyboardShortcut from '@hooks/useKeyboardShortcut';
@@ -41,9 +42,18 @@ function OnboardingModalNavigator() {
     const outerViewRef = React.useRef<View>(null);
     const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
     const {canUsePrivateDomainOnboarding} = usePermissions();
-
     const isOnPrivateDomainAndHasAccessiblePolicies = canUsePrivateDomainOnboarding && !account?.isFromPublicDomain && account?.hasAccessibleDomainPolicies;
 
+    let initialRouteName: ValueOf<typeof SCREENS.ONBOARDING> = SCREENS.ONBOARDING.PURPOSE;
+
+    if (isOnPrivateDomainAndHasAccessiblePolicies) {
+        initialRouteName = SCREENS.ONBOARDING.PERSONAL_DETAILS;
+    }
+
+    if (account?.isFromPublicDomain) {
+        initialRouteName = SCREENS.ONBOARDING.WORK_EMAIL;
+    }
+
     const [accountID] = useOnyx(ONYXKEYS.SESSION, {
         selector: (session) => session?.accountID ?? CONST.DEFAULT_NUMBER_ID,
         canBeMissing: false,
@@ -65,6 +75,11 @@ function OnboardingModalNavigator() {
 
     useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.ESCAPE, handleOuterClick, {shouldBubble: true});
 
+    // If the account data is not loaded yet, we don't want to show the onboarding modal
+    if (isOnPrivateDomainAndHasAccessiblePolicies === undefined) {
+        return null;
+    }
+
     return (
         <NoDropZone>
             <Overlay />
@@ -78,15 +93,14 @@ function OnboardingModalNavigator() {
                         onClick={(e) => e.stopPropagation()}
                         style={styles.OnboardingNavigatorInnerView(onboardingIsMediumOrLargerScreenWidth)}
                     >
-                        <Stack.Navigator screenOptions={defaultScreenOptions}>
-                            {/* The OnboardingPurpose screen is shown after the workspace step when the user is on a private domain and has accessible policies.
-                             */}
-                            {!isOnPrivateDomainAndHasAccessiblePolicies && (
-                                <Stack.Screen
-                                    name={SCREENS.ONBOARDING.PURPOSE}
-                                    component={OnboardingPurpose}
-                                />
-                            )}
+                        <Stack.Navigator
+                            screenOptions={defaultScreenOptions}
+                            initialRouteName={initialRouteName}
+                        >
+                            <Stack.Screen
+                                name={SCREENS.ONBOARDING.PURPOSE}
+                                component={OnboardingPurpose}
+                            />
                             <Stack.Screen
                                 name={SCREENS.ONBOARDING.PERSONAL_DETAILS}
                                 component={OnboardingPersonalDetails}
@@ -107,14 +121,6 @@ function OnboardingModalNavigator() {
                                 name={SCREENS.ONBOARDING.WORKSPACES}
                                 component={OnboardingWorkspaces}
                             />
-                            {/* The OnboardingPurpose screen is only shown after the workspace step when the user is on a private domain and has accessible policies
-                             */}
-                            {!!isOnPrivateDomainAndHasAccessiblePolicies && (
-                                <Stack.Screen
-                                    name={SCREENS.ONBOARDING.PURPOSE}
-                                    component={OnboardingPurpose}
-                                />
-                            )}
                             <Stack.Screen
                                 name={SCREENS.ONBOARDING.EMPLOYEES}
                                 component={OnboardingEmployees}
diff --git a/src/libs/Navigation/NavigationRoot.tsx b/src/libs/Navigation/NavigationRoot.tsx
index 0c42792cb376..477283ed4219 100644
--- a/src/libs/Navigation/NavigationRoot.tsx
+++ b/src/libs/Navigation/NavigationRoot.tsx
@@ -4,6 +4,7 @@ import React, {useContext, useEffect, useMemo, useRef} from 'react';
 import {useOnyx} from 'react-native-onyx';
 import {ScrollOffsetContext} from '@components/ScrollOffsetContextProvider';
 import useCurrentReportID from '@hooks/useCurrentReportID';
+import usePermissions from '@hooks/usePermissions';
 import usePrevious from '@hooks/usePrevious';
 import useResponsiveLayout from '@hooks/useResponsiveLayout';
 import useTheme from '@hooks/useTheme';
@@ -105,6 +106,8 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady}: N
 
     const previousAuthenticated = usePrevious(authenticated);
 
+    const {canUsePrivateDomainOnboarding} = usePermissions();
+
     const initialState = useMemo(() => {
         const path = initialUrl ? getPathFromURL(initialUrl) : null;
         if (path?.includes(ROUTES.MIGRATED_USER_WELCOME_MODAL.route) && lastVisitedPath && isOnboardingCompleted && authenticated) {
@@ -129,7 +132,14 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady}: N
         // If the user haven't completed the flow, we want to always redirect them to the onboarding flow.
         // We also make sure that the user is authenticated, isn't part of a group workspace, isn't in the transition flow & wasn't invited to NewDot.
         if (!CONFIG.IS_HYBRID_APP && !hasNonPersonalPolicy && !isOnboardingCompleted && !wasInvitedToNewDot && authenticated && !isTransitioning) {
-            return getAdaptedStateFromPath(getOnboardingInitialPath(), linkingConfig.config);
+            return getAdaptedStateFromPath(
+                getOnboardingInitialPath({
+                    canUsePrivateDomainOnboarding,
+                    isUserFromPublicDomain: !!account.isFromPublicDomain,
+                    hasAccessiblePolicies: !!account.hasAccessibleDomainPolicies,
+                }),
+                linkingConfig.config,
+            );
         }
 
         // If there is no lastVisitedPath, we can do early return. We won't modify the default behavior.
diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts
index ec3a406131fb..0716f6ea08d2 100644
--- a/src/libs/actions/Report.ts
+++ b/src/libs/actions/Report.ts
@@ -156,6 +156,7 @@ import type {Route} from '@src/ROUTES';
 import ROUTES from '@src/ROUTES';
 import INPUT_IDS from '@src/types/form/NewRoomForm';
 import type {
+    Account,
     DismissedProductTraining,
     IntroSelected,
     InvitedEmailsToAccountIDs,
@@ -315,6 +316,14 @@ Onyx.connect({
     },
 });
 
+let account: OnyxEntry<Account> = {};
+Onyx.connect({
+    key: ONYXKEYS.ACCOUNT,
+    callback: (value) => {
+        account = value ?? {};
+    },
+});
+
 const draftNoteMap: OnyxCollection<string> = {};
 Onyx.connect({
     key: ONYXKEYS.COLLECTION.PRIVATE_NOTES_DRAFT,
@@ -3345,7 +3354,12 @@ function openReportFromDeepLink(url: string) {
                         }
                         // We need skip deeplinking if the user hasn't completed the guided setup flow.
                         isOnboardingFlowCompleted({
-                            onNotCompleted: () => startOnboardingFlow(undefined, val),
+                            onNotCompleted: () =>
+                                startOnboardingFlow({
+                                    onboardingValuesParam: val,
+                                    hasAccessiblePolicies: !!account?.hasAccessibleDomainPolicies,
+                                    isUserFromPublicDomain: !!account?.isFromPublicDomain,
+                                }),
                             onCompleted: handleDeeplinkNavigation,
                             onCanceled: handleDeeplinkNavigation,
                         });
diff --git a/src/libs/actions/Welcome/OnboardingFlow.ts b/src/libs/actions/Welcome/OnboardingFlow.ts
index 4eae433441ab..fd48efbd4f6a 100644
--- a/src/libs/actions/Welcome/OnboardingFlow.ts
+++ b/src/libs/actions/Welcome/OnboardingFlow.ts
@@ -34,12 +34,19 @@ Onyx.connect({
     },
 });
 
+type GetOnboardingInitialPathParamsType = {
+    isUserFromPublicDomain: boolean;
+    hasAccessiblePolicies: boolean;
+    onboardingValuesParam?: Onboarding;
+    canUsePrivateDomainOnboarding?: boolean;
+};
+
 /**
  * Start a new onboarding flow or continue from the last visited onboarding page.
  */
-function startOnboardingFlow(isPrivateDomain?: boolean, onboardingValuesParam?: Onboarding, isUserFromPublicDomain?: boolean) {
+function startOnboardingFlow(startOnboardingFlowParams: GetOnboardingInitialPathParamsType) {
     const currentRoute = navigationRef.getCurrentRoute();
-    const adaptedState = getAdaptedStateFromPath(getOnboardingInitialPath(isPrivateDomain, onboardingValuesParam, isUserFromPublicDomain), linkingConfig.config, false);
+    const adaptedState = getAdaptedStateFromPath(getOnboardingInitialPath(startOnboardingFlowParams), linkingConfig.config, false);
     const focusedRoute = findFocusedRoute(adaptedState as PartialState<NavigationState<RootNavigatorParamList>>);
     if (focusedRoute?.name === currentRoute?.name) {
         return;
@@ -51,7 +58,8 @@ function startOnboardingFlow(isPrivateDomain?: boolean, onboardingValuesParam?:
     } as PartialState<NavigationState>);
 }
 
-function getOnboardingInitialPath(isPrivateDomain?: boolean, onboardingValuesParam?: Onboarding, isUserFromPublicDomain?: boolean): string {
+function getOnboardingInitialPath(getOnboardingInitialPathParams: GetOnboardingInitialPathParamsType): string {
+    const {isUserFromPublicDomain, hasAccessiblePolicies, onboardingValuesParam, canUsePrivateDomainOnboarding} = getOnboardingInitialPathParams;
     const state = getStateFromPath(onboardingInitialPath, linkingConfig.config);
     const currentOnboardingValues = onboardingValuesParam ?? onboardingValues;
     const isVsb = currentOnboardingValues?.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.VSB;
@@ -72,6 +80,11 @@ function getOnboardingInitialPath(isPrivateDomain?: boolean, onboardingValuesPar
     if (isUserFromPublicDomain && !onboardingValuesParam?.isMergeAccountStepCompleted) {
         return `/${ROUTES.ONBOARDING_WORK_EMAIL.route}`;
     }
+
+    if (!isUserFromPublicDomain && hasAccessiblePolicies && canUsePrivateDomainOnboarding) {
+        return `/${ROUTES.ONBOARDING_PERSONAL_DETAILS.route}`;
+    }
+
     if (isVsb) {
         return `/${ROUTES.ONBOARDING_ACCOUNTING.route}`;
     }
@@ -79,10 +92,6 @@ function getOnboardingInitialPath(isPrivateDomain?: boolean, onboardingValuesPar
         return `/${ROUTES.ONBOARDING_EMPLOYEES.route}`;
     }
 
-    if (isPrivateDomain) {
-        return `/${ROUTES.ONBOARDING_PERSONAL_DETAILS.route}`;
-    }
-
     if (state?.routes?.at(-1)?.name !== NAVIGATORS.ONBOARDING_MODAL_NAVIGATOR) {
         return `/${ROUTES.ONBOARDING_ROOT.route}`;
     }
diff --git a/src/pages/OnboardingPrivateDomain/BaseOnboardingPrivateDomain.tsx b/src/pages/OnboardingPrivateDomain/BaseOnboardingPrivateDomain.tsx
index f78f04ade6e1..be15bf44326a 100644
--- a/src/pages/OnboardingPrivateDomain/BaseOnboardingPrivateDomain.tsx
+++ b/src/pages/OnboardingPrivateDomain/BaseOnboardingPrivateDomain.tsx
@@ -21,10 +21,9 @@ function BaseOnboardingPrivateDomain({shouldUseNativeStyles, route}: BaseOnboard
     const [hasMagicCodeBeenSent, setHasMagicCodeBeenSent] = useState(false);
     const styles = useThemeStyles();
     const {translate} = useLocalize();
-    const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST, {canBeMissing: true});
+    const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST, {canBeMissing: false});
 
-    const [credentials] = useOnyx(ONYXKEYS.CREDENTIALS, {canBeMissing: true});
-    const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: true});
+    const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false});
 
     const [getAccessiblePoliciesAction] = useOnyx(ONYXKEYS.VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES, {canBeMissing: true});
     const [joinablePolicies] = useOnyx(ONYXKEYS.JOINABLE_POLICIES, {canBeMissing: true});
@@ -38,11 +37,11 @@ function BaseOnboardingPrivateDomain({shouldUseNativeStyles, route}: BaseOnboard
     const isValidated = isCurrentUserValidated(loginList);
 
     const sendValidateCode = useCallback(() => {
-        if (!credentials?.login) {
+        if (!email) {
             return;
         }
-        resendValidateCode(credentials.login);
-    }, [credentials?.login]);
+        resendValidateCode(email);
+    }, [email]);
 
     useEffect(() => {
         if (isValidated) {


Reviews:
user: login: parasharrajat
state: CHANGES_REQUESTED
author_association: MEMBER
submitted_at: 2025-04-29T08:43:48Z
user: login: allroundexperts
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-29T23:11:48Z
user: login: parasharrajat
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-01T18:53:59Z
user: login: allroundexperts
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-01T19:12:51Z
user: login: parasharrajat
body: ## Reviewer Checklist

- [x] I have verified the author checklist is complete (all boxes are checked off).
- [x] I verified the correct issue is linked in the `### Fixed Issues` section above
- [x] I verified testing steps are clear and they cover the changes made in this PR
    - [x] I verified the steps for local testing are in the `Tests` section
    - [x] I verified the steps for Staging and/or Production testing are in the `QA steps` section
    - [x] I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    - [x] I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
- [x] I checked that screenshots or videos are included for tests on [all platforms](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md#make-sure-you-can-test-on-all-platforms)
- [x] I included screenshots or videos for tests on [all platforms](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md#make-sure-you-can-test-on-all-platforms)
- [x] I verified tests pass on **all platforms** & I tested again on:
    - [x] Android: Native
    - [x] Android: mWeb Chrome
    - [x] iOS: Native
    - [x] iOS: mWeb Safari
    - [x] MacOS: Chrome / Safari
    - [x] MacOS: Desktop
- [x] If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
- [x] I verified proper code patterns were followed (see [Reviewing the code](https://github.com/Expensify/App/blob/main/contributingGuides/PR_REVIEW_GUIDELINES.md#reviewing-the-code))
    - [x] I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. `toggleReport` and not `onIconClick`).
    - [x] I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. `myBool && <MyComponent />`.
    - [x] I verified that comments were added to code that is not self explanatory
    - [x] I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    - [x] I verified any copy / text shown in the product is localized by adding it to `src/languages/*` files and using the [translation method](https://github.com/Expensify/App/blob/4bd99402cebdf4d7394e0d1f260879ea238197eb/src/components/withLocalize.js#L60)
    - [x] I verified all numbers, amounts, dates and phone numbers shown in the product are using the [localization methods](https://github.com/Expensify/App/blob/4bd99402cebdf4d7394e0d1f260879ea238197eb/src/components/withLocalize.js#L60-L68)
    - [x] I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the `Waiting for Copy` label for a copy review on the original GH to get the correct copy.
    - [x] I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    - [x] I verified the JSDocs style guidelines (in [`STYLE.md`](https://github.com/Expensify/App/blob/main/contributingGuides/STYLE.md#jsdocs)) were followed
- [x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
- [x] I verified that this PR follows the guidelines as stated in the [Review Guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/PR_REVIEW_GUIDELINES.md)
- [x] I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like `Avatar`, I verified the components using `Avatar` have been tested & I retested again)
- [x] I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
- [x] I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
- [x] If a new component is created I verified that:
    - [x] A similar component doesn't exist in the codebase
    - [x] All props are defined accurately and each prop has a `/** comment above it */`
    - [x] The file is named correctly
    - [x] The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    - [x] The only data being stored in the state is data necessary for rendering and nothing else
    - [x] For Class Components, any internal methods passed to components event handlers are bound to `this` properly so there are no scoping issues (i.e. for `onClick={this.submit}` the method `this.submit` should be bound to `this` in the constructor)
    - [x] Any internal methods bound to `this` are necessary to be bound (i.e. avoid `this.submit = this.submit.bind(this);` if `this.submit` is never passed to a component event handler like `onClick`)
    - [x] All JSX used for rendering exists in the render method
    - [x] The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
- [x] If any new file was added I verified that:
    - [x] The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
- [x] If a new CSS style is added I verified that:
    - [x] A similar style doesn't already exist
    - [x] The style can't be created with an existing [StyleUtils](https://github.com/Expensify/App/blob/main/src/utils/index.ts) function (i.e. `StyleUtils.getBackgroundAndBorderStyle(theme.componentBG`)
- [x] If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
- [x] If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like `Avatar` is modified, I verified that `Avatar` is working as expected in all cases)
- [x] If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
- [x] If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
- [x] If the PR modifies the form input styles:
    - [x] I verified that all the inputs inside a form are aligned with each other.
    - [x] I added `Design` label so the design team can review the changes.
- [x] If a new page is added, I verified it's using the `ScrollView` component to make it scrollable when more elements are added to the page.
- [x] If the `main` branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the `Test` steps.
- [x] I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.


:ribbon: :eyes: :ribbon:  C+ reviewed
state: APPROVED
author_association: MEMBER
submitted_at: 2025-05-06T09:27:06Z
user: login: allgandalf
state: DISMISSED
author_association: CONTRIBUTOR
submitted_at: 2025-05-12T08:28:50Z
user: login: allroundexperts
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-13T22:40:34Z
user: login: allgandalf
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-14T03:39:57Z
user: login: blimpich
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-15T20:57:14Z
user: login: allroundexperts
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-15T22:49:22Z
user: login: allroundexperts
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-15T23:33:46Z
user: login: allgandalf
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-16T08:14:24Z
user: login: allgandalf
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-16T08:15:17Z
user: login: allroundexperts
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-16T13:13:37Z
user: login: blimpich
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-19T22:45:21Z
user: login: allroundexperts
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-19T23:09:45Z
user: login: blimpich
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-19T23:39:34Z
user: login: blimpich
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-19T23:52:09Z
user: login: blimpich
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-05-20T22:52:31Z

Review comments:
diff_hunk: @@ -79,14 +74,10 @@ function OnboardingModalNavigator() {
                         style={styles.OnboardingNavigatorInnerView(onboardingIsMediumOrLargerScreenWidth)}
                     >
                         <Stack.Navigator screenOptions={defaultScreenOptions}>
-                            {/* The OnboardingPurpose screen is shown after the workspace step when the user is on a private domain and has accessible policies.
-                             */}
-                            {!isOnPrivateDomainAndHasAccessiblePolicies && (
-                                <Stack.Screen
-                                    name={SCREENS.ONBOARDING.PURPOSE}
-                                    component={OnboardingPurpose}
-                                />
-                            )}
path: src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx
user: login: parasharrajat
body: I think it was fixing a issue earlier from the main PR. Why are we removing this?
created_at: 2025-04-29T08:42:44Z
author_association: MEMBER
diff_hunk: @@ -79,14 +74,10 @@ function OnboardingModalNavigator() {
                         style={styles.OnboardingNavigatorInnerView(onboardingIsMediumOrLargerScreenWidth)}
                     >
                         <Stack.Navigator screenOptions={defaultScreenOptions}>
-                            {/* The OnboardingPurpose screen is shown after the workspace step when the user is on a private domain and has accessible policies.
-                             */}
-                            {!isOnPrivateDomainAndHasAccessiblePolicies && (
-                                <Stack.Screen
-                                    name={SCREENS.ONBOARDING.PURPOSE}
-                                    component={OnboardingPurpose}
-                                />
-                            )}
path: src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx
user: login: allroundexperts
body: We are removing it because it was causing regression as per [this comment](https://github.com/Expensify/App/issues/60763#issuecomment-2829306726). I wasn't able to reproduce the issue we had earlier after removing [this](https://github.com/Expensify/App/pull/54912#issuecomment-2773610789)

https://github.com/user-attachments/assets/6b02512c-594a-4114-bb24-c6f83f5c6765

created_at: 2025-04-29T23:11:48Z
author_association: CONTRIBUTOR
diff_hunk: @@ -63,7 +63,7 @@ function startOnboardingFlow(isPrivateDomain?: boolean) {
     } as PartialState<NavigationState>);
 }
 
-function getOnboardingInitialPath(isPrivateDomain?: boolean): string {
+function getOnboardingInitialPath(canUsePrivateDomainOnboarding = true): string {
path: src/libs/actions/Welcome/OnboardingFlow.ts
user: login: parasharrajat
body: ```suggestion
function getOnboardingInitialPath(canUsePrivateDomainOnboarding = false): string {
```

Shouldn't this be false by default? We should be checking the beta before making this true all the time.
created_at: 2025-05-01T18:53:59Z
author_association: MEMBER
diff_hunk: @@ -63,7 +63,7 @@ function startOnboardingFlow(isPrivateDomain?: boolean) {
     } as PartialState<NavigationState>);
 }
 
-function getOnboardingInitialPath(isPrivateDomain?: boolean): string {
+function getOnboardingInitialPath(canUsePrivateDomainOnboarding = true): string {
path: src/libs/actions/Welcome/OnboardingFlow.ts
user: login: allroundexperts
body: Sure, done!
created_at: 2025-05-01T19:12:51Z
author_association: CONTRIBUTOR
diff_hunk: @@ -41,9 +42,18 @@ function OnboardingModalNavigator() {
     const outerViewRef = React.useRef<View>(null);
     const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
     const {canUsePrivateDomainOnboarding} = usePermissions();
-
     const isOnPrivateDomainAndHasAccessiblePolicies = canUsePrivateDomainOnboarding && !account?.isFromPublicDomain && account?.hasAccessibleDomainPolicies;
 
+    let initialRouteName: ValueOf<typeof SCREENS.ONBOARDING> = SCREENS.ONBOARDING.PURPOSE;
+
+    if (isOnPrivateDomainAndHasAccessiblePolicies) {
+        initialRouteName = SCREENS.ONBOARDING.PERSONAL_DETAILS;
+    }
+
+    if (account?.isFromPublicDomain) {
+        initialRouteName = SCREENS.ONBOARDING.WORK_EMAIL;
+    }
+
path: src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx
user: login: allgandalf
body: We have navigation logic set in `onboardingFlow.ts`, lets not decide the inital scren in navigator, when onboarding was build, we purposely, created a hook and and a intial screen function to avoid this confusion, please do all the initial navigation logic in this file:

https://github.com/Expensify/App/blob/main/src/libs/actions/Welcome/OnboardingFlow.ts
created_at: 2025-05-12T08:26:48Z
author_association: CONTRIBUTOR
diff_hunk: @@ -105,6 +106,8 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady}: N
 
     const previousAuthenticated = usePrevious(authenticated);
 
+    const {canUsePrivateDomainOnboarding} = usePermissions();
path: src/libs/Navigation/NavigationRoot.tsx
user: login: allgandalf
body: If we already decide in onboardingFlow.ts that we won't navigate to the private domain screen, then all of these changes become insignificant, lets remove these and do it in a centralised place
created_at: 2025-05-12T08:28:45Z
author_association: CONTRIBUTOR
diff_hunk: @@ -41,9 +42,18 @@ function OnboardingModalNavigator() {
     const outerViewRef = React.useRef<View>(null);
     const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
     const {canUsePrivateDomainOnboarding} = usePermissions();
-
     const isOnPrivateDomainAndHasAccessiblePolicies = canUsePrivateDomainOnboarding && !account?.isFromPublicDomain && account?.hasAccessibleDomainPolicies;
 
+    let initialRouteName: ValueOf<typeof SCREENS.ONBOARDING> = SCREENS.ONBOARDING.PURPOSE;
+
+    if (isOnPrivateDomainAndHasAccessiblePolicies) {
+        initialRouteName = SCREENS.ONBOARDING.PERSONAL_DETAILS;
+    }
+
+    if (account?.isFromPublicDomain) {
+        initialRouteName = SCREENS.ONBOARDING.WORK_EMAIL;
+    }
+
path: src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx
user: login: allroundexperts
body: That introduced [this](https://github.com/Expensify/App/pull/60990#issuecomment-2851454771) bug. I'm okay with removing it if we are fine with the above bug.
created_at: 2025-05-13T22:40:34Z
author_association: CONTRIBUTOR
diff_hunk: @@ -41,9 +42,18 @@ function OnboardingModalNavigator() {
     const outerViewRef = React.useRef<View>(null);
     const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
     const {canUsePrivateDomainOnboarding} = usePermissions();
-
     const isOnPrivateDomainAndHasAccessiblePolicies = canUsePrivateDomainOnboarding && !account?.isFromPublicDomain && account?.hasAccessibleDomainPolicies;
 
+    let initialRouteName: ValueOf<typeof SCREENS.ONBOARDING> = SCREENS.ONBOARDING.PURPOSE;
+
+    if (isOnPrivateDomainAndHasAccessiblePolicies) {
+        initialRouteName = SCREENS.ONBOARDING.PERSONAL_DETAILS;
+    }
+
+    if (account?.isFromPublicDomain) {
+        initialRouteName = SCREENS.ONBOARDING.WORK_EMAIL;
+    }
+
path: src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx
user: login: allgandalf
body: that was happening because of the BE bug with the `user` object, i think we are just fine now, can you test again?

created_at: 2025-05-14T03:39:57Z
author_association: CONTRIBUTOR
diff_hunk: @@ -41,9 +42,18 @@ function OnboardingModalNavigator() {
     const outerViewRef = React.useRef<View>(null);
     const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
     const {canUsePrivateDomainOnboarding} = usePermissions();
-
     const isOnPrivateDomainAndHasAccessiblePolicies = canUsePrivateDomainOnboarding && !account?.isFromPublicDomain && account?.hasAccessibleDomainPolicies;
 
+    let initialRouteName: ValueOf<typeof SCREENS.ONBOARDING> = SCREENS.ONBOARDING.PURPOSE;
+
+    if (isOnPrivateDomainAndHasAccessiblePolicies) {
+        initialRouteName = SCREENS.ONBOARDING.PERSONAL_DETAILS;
+    }
+
+    if (account?.isFromPublicDomain) {
+        initialRouteName = SCREENS.ONBOARDING.WORK_EMAIL;
+    }
+
path: src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx
user: login: blimpich
body: @allroundexperts any update here to Gandalf's comment?
created_at: 2025-05-15T20:57:14Z
author_association: CONTRIBUTOR
diff_hunk: @@ -41,9 +42,18 @@ function OnboardingModalNavigator() {
     const outerViewRef = React.useRef<View>(null);
     const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
     const {canUsePrivateDomainOnboarding} = usePermissions();
-
     const isOnPrivateDomainAndHasAccessiblePolicies = canUsePrivateDomainOnboarding && !account?.isFromPublicDomain && account?.hasAccessibleDomainPolicies;
 
+    let initialRouteName: ValueOf<typeof SCREENS.ONBOARDING> = SCREENS.ONBOARDING.PURPOSE;
+
+    if (isOnPrivateDomainAndHasAccessiblePolicies) {
+        initialRouteName = SCREENS.ONBOARDING.PERSONAL_DETAILS;
+    }
+
+    if (account?.isFromPublicDomain) {
+        initialRouteName = SCREENS.ONBOARDING.WORK_EMAIL;
+    }
+
path: src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx
user: login: allroundexperts
body: Checking now.
created_at: 2025-05-15T22:49:22Z
author_association: CONTRIBUTOR
diff_hunk: @@ -41,9 +42,18 @@ function OnboardingModalNavigator() {
     const outerViewRef = React.useRef<View>(null);
     const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
     const {canUsePrivateDomainOnboarding} = usePermissions();
-
     const isOnPrivateDomainAndHasAccessiblePolicies = canUsePrivateDomainOnboarding && !account?.isFromPublicDomain && account?.hasAccessibleDomainPolicies;
 
+    let initialRouteName: ValueOf<typeof SCREENS.ONBOARDING> = SCREENS.ONBOARDING.PURPOSE;
+
+    if (isOnPrivateDomainAndHasAccessiblePolicies) {
+        initialRouteName = SCREENS.ONBOARDING.PERSONAL_DETAILS;
+    }
+
+    if (account?.isFromPublicDomain) {
+        initialRouteName = SCREENS.ONBOARDING.WORK_EMAIL;
+    }
+
path: src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx
user: login: allroundexperts
body: Just tested on the latest main, and I can not see the private domain step on Android

https://github.com/user-attachments/assets/a744b7c7-d020-4b83-b808-18d3de48bc83


created_at: 2025-05-15T23:33:46Z
author_association: CONTRIBUTOR
diff_hunk: @@ -41,9 +42,18 @@ function OnboardingModalNavigator() {
     const outerViewRef = React.useRef<View>(null);
     const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
     const {canUsePrivateDomainOnboarding} = usePermissions();
-
     const isOnPrivateDomainAndHasAccessiblePolicies = canUsePrivateDomainOnboarding && !account?.isFromPublicDomain && account?.hasAccessibleDomainPolicies;
 
+    let initialRouteName: ValueOf<typeof SCREENS.ONBOARDING> = SCREENS.ONBOARDING.PURPOSE;
+
+    if (isOnPrivateDomainAndHasAccessiblePolicies) {
+        initialRouteName = SCREENS.ONBOARDING.PERSONAL_DETAILS;
+    }
+
+    if (account?.isFromPublicDomain) {
+        initialRouteName = SCREENS.ONBOARDING.WORK_EMAIL;
+    }
+
path: src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx
user: login: allgandalf
body: QA created an issue for that today:

- https://github.com/Expensify/App/issues/62167
created_at: 2025-05-16T08:14:24Z
author_association: CONTRIBUTOR
diff_hunk: @@ -41,9 +42,18 @@ function OnboardingModalNavigator() {
     const outerViewRef = React.useRef<View>(null);
     const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
     const {canUsePrivateDomainOnboarding} = usePermissions();
-
     const isOnPrivateDomainAndHasAccessiblePolicies = canUsePrivateDomainOnboarding && !account?.isFromPublicDomain && account?.hasAccessibleDomainPolicies;
 
+    let initialRouteName: ValueOf<typeof SCREENS.ONBOARDING> = SCREENS.ONBOARDING.PURPOSE;
+
+    if (isOnPrivateDomainAndHasAccessiblePolicies) {
+        initialRouteName = SCREENS.ONBOARDING.PERSONAL_DETAILS;
+    }
+
+    if (account?.isFromPublicDomain) {
+        initialRouteName = SCREENS.ONBOARDING.WORK_EMAIL;
+    }
+
path: src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx
user: login: allgandalf
body: @allroundexperts to be clear, does it also affect iOS?
created_at: 2025-05-16T08:15:17Z
author_association: CONTRIBUTOR
diff_hunk: @@ -41,9 +42,18 @@ function OnboardingModalNavigator() {
     const outerViewRef = React.useRef<View>(null);
     const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
     const {canUsePrivateDomainOnboarding} = usePermissions();
-
     const isOnPrivateDomainAndHasAccessiblePolicies = canUsePrivateDomainOnboarding && !account?.isFromPublicDomain && account?.hasAccessibleDomainPolicies;
 
+    let initialRouteName: ValueOf<typeof SCREENS.ONBOARDING> = SCREENS.ONBOARDING.PURPOSE;
+
+    if (isOnPrivateDomainAndHasAccessiblePolicies) {
+        initialRouteName = SCREENS.ONBOARDING.PERSONAL_DETAILS;
+    }
+
+    if (account?.isFromPublicDomain) {
+        initialRouteName = SCREENS.ONBOARDING.WORK_EMAIL;
+    }
+
path: src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx
user: login: allroundexperts
body: Only android
created_at: 2025-05-16T13:13:36Z
author_association: CONTRIBUTOR
diff_hunk: @@ -105,6 +106,8 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady}: N
 
     const previousAuthenticated = usePrevious(authenticated);
 
+    const {canUsePrivateDomainOnboarding} = usePermissions();
path: src/libs/Navigation/NavigationRoot.tsx
user: login: blimpich
body: @allroundexperts have you addressed this? If so can you resolve the comment?
created_at: 2025-05-19T22:45:21Z
author_association: CONTRIBUTOR
diff_hunk: @@ -105,6 +106,8 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady}: N
 
     const previousAuthenticated = usePrevious(authenticated);
 
+    const {canUsePrivateDomainOnboarding} = usePermissions();
path: src/libs/Navigation/NavigationRoot.tsx
user: login: allroundexperts
body: I am not sure if this needs to be addressed. We need it to prevent the bug that is discussed above.
created_at: 2025-05-19T23:09:45Z
author_association: CONTRIBUTOR
diff_hunk: @@ -41,9 +42,18 @@ function OnboardingModalNavigator() {
     const outerViewRef = React.useRef<View>(null);
     const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
     const {canUsePrivateDomainOnboarding} = usePermissions();
-
     const isOnPrivateDomainAndHasAccessiblePolicies = canUsePrivateDomainOnboarding && !account?.isFromPublicDomain && account?.hasAccessibleDomainPolicies;
 
+    let initialRouteName: ValueOf<typeof SCREENS.ONBOARDING> = SCREENS.ONBOARDING.PURPOSE;
+
+    if (isOnPrivateDomainAndHasAccessiblePolicies) {
+        initialRouteName = SCREENS.ONBOARDING.PERSONAL_DETAILS;
+    }
+
+    if (account?.isFromPublicDomain) {
+        initialRouteName = SCREENS.ONBOARDING.WORK_EMAIL;
+    }
+
path: src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx
user: login: blimpich
body: That bug doesn't reproduce for me anymore ([link](https://github.com/Expensify/App/issues/62167#issuecomment-2892462916)). Taking this to [slack](https://expensify.slack.com/archives/C01GTK53T8Q/p1747698176818409) as I think this is the last thing blocking this PR.
created_at: 2025-05-19T23:39:33Z
author_association: CONTRIBUTOR
diff_hunk: @@ -105,6 +106,8 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady}: N
 
     const previousAuthenticated = usePrevious(authenticated);
 
+    const {canUsePrivateDomainOnboarding} = usePermissions();
path: src/libs/Navigation/NavigationRoot.tsx
user: login: blimpich
body: You are right, main conversation is in other thread. My bad!
created_at: 2025-05-19T23:52:09Z
author_association: CONTRIBUTOR

PR comments:
user: login: melvin-bot[bot]
created_at: 2025-04-28T22:35:34Z
body: @parasharrajat Please copy/paste the Reviewer Checklist from [here](https://raw.githubusercontent.com/Expensify/App/main/contributingGuides/REVIEWER_CHECKLIST.md) into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]
author_association: NONE
user: login: blimpich
created_at: 2025-04-28T23:37:49Z
body: Should we get rid of the [private domain onboarding beta](https://github.com/Expensify/App/pull/60888/files) entirely as part of this PR? Or should we wait till it passes QA to completely get rid of the beta?
author_association: CONTRIBUTOR
user: login: allroundexperts
created_at: 2025-04-29T22:53:46Z
body: > Should we get rid of the [private domain onboarding beta](https://github.com/Expensify/App/pull/60888/files) entirely as part of this PR? Or should we wait till it passes QA to completely get rid of the beta?

I think we should wait till it passes QA.
author_association: CONTRIBUTOR
user: login: parasharrajat
created_at: 2025-04-30T08:22:07Z
body: Testing...
author_association: MEMBER
user: login: parasharrajat
created_at: 2025-05-01T22:28:25Z
body: BUG: Web: Can't submit the personal details step on login with a private domain email which does not have any workspaces. 

1. Log in with a new private domain email where no workspace exists before. 
2. Notice that you land on the personal details step. 
3. Add details and press continue. 

Bug: Nothing happens on pressing continue. 

Bug: User is directly taken to the personal details step instead of purpose screen. 


https://github.com/user-attachments/assets/dc72a621-b07c-4837-aab2-b2fcbddead02




author_association: MEMBER
user: login: allroundexperts
created_at: 2025-05-05T09:29:44Z
body: > BUG: Web: Can't submit the personal details step on login with a private domain email which does not have any workspaces.
> 
> 1. Log in with a new private domain email where no workspace exists before.
> 2. Notice that you land on the personal details step.
> 3. Add details and press continue.
> 
> Bug: Nothing happens on pressing continue.
> 
> Bug: User is directly taken to the personal details step instead of purpose screen.
> 
>  02.05.2025_03.46.32_REC.mp4

Fixed @parasharrajat 
author_association: CONTRIBUTOR
user: login: parasharrajat
created_at: 2025-05-05T11:07:50Z
body: > Bug: Nothing happens on pressing continue.

> Bug: User is directly taken to the personal details step instead of purpose screen.

@allroundexperts Did you fix both issues? 


author_association: MEMBER
user: login: parasharrajat
created_at: 2025-05-05T12:47:40Z
body: BUG: User does not land directly on Personal details step with private email. 


https://github.com/user-attachments/assets/fff69721-fbdd-4d5d-8b4e-37dfa70c24ad


author_association: MEMBER
user: login: allroundexperts
created_at: 2025-05-05T13:30:16Z
body: > @allroundexperts Did you fix both issues?

Yes.
author_association: CONTRIBUTOR
user: login: allroundexperts
created_at: 2025-05-05T13:33:47Z
body: > BUG: User does not land directly on Personal details step with private email.

Does this domain have any workspaces?
author_association: CONTRIBUTOR
user: login: parasharrajat
created_at: 2025-05-05T13:34:05Z
body: Yes, it has.
author_association: MEMBER
user: login: allroundexperts
created_at: 2025-05-05T15:55:39Z
body: This is happening because purpose screen is higher up in the stack than the personal information stack. I tried to change it in my previous PR but that caused https://github.com/Expensify/App/issues/60763.

I really think that the correct fix is moving the screen position along the stack. The same issue exists for the public email flow as well because its relying on the `getInitialRoute` only.

https://github.com/user-attachments/assets/2eca31a4-3853-42b9-b529-283815a3c105

I am kind of stumped here, @blimpich what are your thoughts?

cc @allgandalf 
author_association: CONTRIBUTOR
user: login: allroundexperts
created_at: 2025-05-06T09:20:47Z
body: @parasharrajat Any update?
author_association: CONTRIBUTOR
user: login: parasharrajat
created_at: 2025-05-06T09:24:33Z
body: ### Screenshots

#### :black_square_button: iOS / native

https://github.com/user-attachments/assets/aa4b7497-d84f-482f-8f16-2da912dffd02


#### :black_square_button: iOS / Safari



https://github.com/user-attachments/assets/6b70eb0a-9674-449f-9a93-73378bc88981



#### :black_square_button: MacOS / Desktop

https://github.com/user-attachments/assets/ecc3cceb-7cab-4b4e-bed5-95daabc423f1


#### :black_square_button: MacOS / Chrome

https://github.com/user-attachments/assets/07b66245-8406-4033-a617-fb8727a0b655


#### :black_square_button: Android / Chrome

https://github.com/user-attachments/assets/5fa47c92-b6c8-4ce5-b04d-2b9410392714


#### :black_square_button: Android / native

https://github.com/user-attachments/assets/1bea8a8d-eba0-46fa-be97-27c2305ee62f


https://github.com/user-attachments/assets/84b26309-3dff-455e-b4be-82f44731d59b


author_association: MEMBER
user: login: parasharrajat
created_at: 2025-05-06T09:26:21Z
body: For reference: I noticed on iOS Safari that after we skip the workspace step and go to the purpose step, pressing the browser back button will take you back to the workspace step.


I am not considering it a bug.
author_association: MEMBER
user: login: github-actions[bot]
created_at: 2025-05-07T00:27:25Z
body: 🚧 @blimpich has triggered a test app build. You can view the [workflow run here](https://github.com/Expensify/App/actions/runs/14872378481).
author_association: CONTRIBUTOR
user: login: blimpich
created_at: 2025-05-07T00:29:35Z
body: started hybrid app ad hoc build to test this, should be done in like an hour
author_association: CONTRIBUTOR
user: login: github-actions[bot]
created_at: 2025-05-07T01:00:08Z
body: :test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! :test_tube::test_tube:
| Android :robot:  | iOS :apple: |
| ------------- | ------------- |
| Android :robot::arrows_counterclockwise:  | iOS :apple::arrows_counterclockwise: |
| https://ad-hoc-expensify-cash.s3.amazonaws.com/android/60990-hybrid/index.html  | https://ad-hoc-expensify-cash.s3.amazonaws.com/ios/60990-hybrid/index.html  |
| ![Android](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=https://ad-hoc-expensify-cash.s3.amazonaws.com/android/60990-hybrid/index.html)  | ![iOS](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=https://ad-hoc-expensify-cash.s3.amazonaws.com/ios/60990-hybrid/index.html)  |
| Desktop :computer: | Web :spider_web: |
| N/A  | N/A  |
| N/A  | N/A  |

---

:eyes: [View the workflow run that generated this build](https://github.com/Expensify/App/actions/runs/14872378481) :eyes:

author_association: CONTRIBUTOR
user: login: blimpich
created_at: 2025-05-07T19:24:03Z
body: Works well except now when I sign in using a public domain and try to add a work email (not tied to any existent account) I get this error. Do we know why this might be happening? cc: @allgandalf 

![Screenshot 2025-05-07 at 12 13 29 PM](https://github.com/user-attachments/assets/7d75ebb1-4a42-4b9b-986c-31f762b4ff40)

author_association: CONTRIBUTOR
user: login: blimpich
created_at: 2025-05-07T19:27:34Z
body: Seems to only happen on hybrid app. I tested on iOS and web, only happened on iOS.
author_association: CONTRIBUTOR
user: login: parasharrajat
created_at: 2025-05-07T19:28:23Z
body: @blimpich That seems unrelated to this PR. If you agree, lets merge this PR and we can discuss that on Slack or original issue.
author_association: MEMBER
user: login: blimpich
created_at: 2025-05-07T19:33:17Z
body: It seems unrelated but if we merge this in we are exposing this bug to users right? I guess its behind beta though correct? So actually users won't see this bug?
author_association: CONTRIBUTOR
user: login: blimpich
created_at: 2025-05-07T19:35:17Z
body: Can you first confirm that this bug won't show to users before we merge?
author_association: CONTRIBUTOR
user: login: blimpich
created_at: 2025-05-07T19:40:13Z
body: ~~I think this might actually be solved by a recent PR. Merging in main locally and testing.~~ Nope, still broke after I merged in main.
author_association: CONTRIBUTOR
user: login: blimpich
created_at: 2025-05-07T20:36:44Z
body: Conversation continued in [Slack thread](https://expensify.slack.com/archives/C01GTK53T8Q/p1746649420335499?thread_ts=1746464779.604049&cid=C01GTK53T8Q)
author_association: CONTRIBUTOR
user: login: blimpich
created_at: 2025-05-08T00:15:44Z
body: We are holding on https://github.com/Expensify/App/issues/61629. That issue has to be fixed first before this gets merged.
author_association: CONTRIBUTOR
user: login: blimpich
created_at: 2025-05-13T21:00:14Z
body: @allroundexperts can you update with latest main? iOS HybridApp private onboarding should work fully now
author_association: CONTRIBUTOR
user: login: allroundexperts
created_at: 2025-05-13T22:39:17Z
body: > @allroundexperts can you update with latest main? iOS HybridApp private onboarding should work fully now

@blimpich Done
author_association: CONTRIBUTOR
user: login: parasharrajat
created_at: 2025-05-20T06:49:45Z
body: What are we waiting on here?
author_association: MEMBER
user: login: blimpich
created_at: 2025-05-20T17:36:26Z
body: > What are we waiting on here?

I was waiting on resolution in this discussion thread https://github.com/Expensify/App/pull/60990#discussion_r2084116019
author_association: CONTRIBUTOR
user: login: OSBotify
created_at: 2025-05-20T23:41:04Z
body: :hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.
author_association: CONTRIBUTOR
user: login: github-actions[bot]
created_at: 2025-05-21T18:29:40Z
body: 🚀 [Deployed](https://github.com/Expensify/App/actions/runs/15169136235) to staging by https://github.com/blimpich in version: 9.1.48-0 🚀

platform | result
---|---
🖥 desktop 🖥|failure ❌
🕸 web 🕸|success ✅
🤖 android 🤖|success ✅
🍎 iOS 🍎|failure ❌
author_association: CONTRIBUTOR
user: login: github-actions[bot]
created_at: 2025-05-21T21:00:21Z
body: 🚀 [Deployed](https://github.com/Expensify/App/actions/runs/15169136235) to staging by https://github.com/blimpich in version: 9.1.48-0 🚀

platform | result
---|---
🖥 desktop 🖥|success ✅
🕸 web 🕸|success ✅
🤖 android 🤖|success ✅
🍎 iOS 🍎|failure ❌
author_association: CONTRIBUTOR
user: login: github-actions[bot]
created_at: 2025-05-22T10:52:20Z
body: 🚀 [Deployed](https://github.com/Expensify/App/actions/runs/15183791423) to staging by https://github.com/blimpich in version: 9.1.49-5 🚀

platform | result
---|---
🖥 desktop 🖥|success ✅
🕸 web 🕸|success ✅
🤖 android 🤖|success ✅
🍎 iOS 🍎|success ✅
author_association: CONTRIBUTOR
user: login: github-actions[bot]
created_at: 2025-05-23T19:04:32Z
body: 🚀 [Deployed](https://github.com/Expensify/App/actions/runs/15217094171) to production by https://github.com/arosiclair in version: 9.1.50-0 🚀

platform | result
---|---
🖥 desktop 🖥|success ✅
🕸 web 🕸|success ✅
🤖 android 🤖|failure ❌
🍎 iOS 🍎|success ✅
author_association: CONTRIBUTOR