Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 3 additions & 23 deletions src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {RouteProp} from '@react-navigation/native';
import type {StackCardInterpolationProps} from '@react-navigation/stack';
import React, {memo, useContext, useEffect, useMemo, useRef, useState} from 'react';
import React, {memo, useContext, useEffect, useRef, useState} from 'react';
import ComposeProviders from '@components/ComposeProviders';
import DelegateNoAccessModalProvider from '@components/DelegateNoAccessModalProvider';
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
Expand All @@ -17,7 +17,6 @@ import useAutoUpdateTimezone from '@hooks/useAutoUpdateTimezone';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useOnboardingFlowRouter from '@hooks/useOnboardingFlow';
import useOnyx from '@hooks/useOnyx';
import usePrevious from '@hooks/usePrevious';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import {SidebarOrderedReportsContextProvider} from '@hooks/useSidebarOrderedReports';
import useStyleUtils from '@hooks/useStyleUtils';
Expand All @@ -36,7 +35,6 @@ import Animations, {InternalPlatformAnimations} from '@libs/Navigation/PlatformS
import Presentation from '@libs/Navigation/PlatformStackNavigation/navigationOptions/presentation';
import type {AuthScreensParamList} from '@libs/Navigation/types';
import NetworkConnection from '@libs/NetworkConnection';
import {shouldOnboardingRedirectToOldDot} from '@libs/OnboardingUtils';
import Pusher from '@libs/Pusher';
import PusherConnectionManager from '@libs/PusherConnectionManager';
import {getReportIDFromLink} from '@libs/ReportUtils';
Expand Down Expand Up @@ -151,10 +149,7 @@ function AuthScreens() {
const [account] = useOnyx(ONYXKEYS.ACCOUNT, {
canBeMissing: true,
});
const [onboardingCompanySize] = useOnyx(ONYXKEYS.ONBOARDING_COMPANY_SIZE, {canBeMissing: true});
const [userReportedIntegration] = useOnyx(ONYXKEYS.ONBOARDING_USER_REPORTED_INTEGRATION, {canBeMissing: true});
const {isOnboardingCompleted, shouldShowRequire2FAPage, isOnboardingLoading} = useOnboardingFlowRouter();
const prevIsOnboardingLoading = usePrevious(isOnboardingLoading);
const {isOnboardingCompleted, shouldShowRequire2FAPage} = useOnboardingFlowRouter();
const {initialURL, isAuthenticatedAtStartup, setIsAuthenticatedAtStartup} = useContext(InitialURLContext);
const modalCardStyleInterpolator = useModalCardStyleInterpolator();

Expand Down Expand Up @@ -184,21 +179,6 @@ function AuthScreens() {
}
};

// On HybridApp we need to prevent flickering during transition to OldDot
const shouldRenderOnboardingExclusivelyOnHybridApp = useMemo(() => {
return CONFIG.IS_HYBRID_APP && Navigation.getActiveRoute().includes(ROUTES.ONBOARDING_INTERESTED_FEATURES.route) && isOnboardingCompleted === true;
}, [isOnboardingCompleted]);

const shouldRenderOnboardingExclusively = useMemo(() => {
return (
!CONFIG.IS_HYBRID_APP &&
Navigation.getActiveRoute().includes(ROUTES.ONBOARDING_INTERESTED_FEATURES.route) &&
shouldOnboardingRedirectToOldDot(onboardingCompanySize, userReportedIntegration) &&
isOnboardingCompleted === true &&
(!!isOnboardingLoading || !!prevIsOnboardingLoading)
);
}, [onboardingCompanySize, isOnboardingCompleted, isOnboardingLoading, prevIsOnboardingLoading, userReportedIntegration]);

useEffect(() => {
if (!Navigation.isActiveRoute(ROUTES.SIGN_IN_MODAL)) {
return;
Expand Down Expand Up @@ -627,7 +607,7 @@ function AuthScreens() {
component={FeatureTrainingModalNavigator}
listeners={modalScreenListeners}
/>
{(isOnboardingCompleted === false || shouldRenderOnboardingExclusivelyOnHybridApp || shouldRenderOnboardingExclusively) && (
{isOnboardingCompleted === false && (
<RootStack.Screen
name={NAVIGATORS.ONBOARDING_MODAL_NAVIGATOR}
options={{...rootNavigatorScreenOptions.basicModalNavigator, gestureEnabled: false}}
Expand Down
34 changes: 0 additions & 34 deletions src/libs/OnboardingUtils.ts

This file was deleted.

36 changes: 5 additions & 31 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ import NetworkConnection from '@libs/NetworkConnection';
import {buildNextStepNew} from '@libs/NextStepUtils';
import LocalNotification from '@libs/Notification/LocalNotification';
import {rand64} from '@libs/NumberUtils';
import {shouldOnboardingRedirectToOldDot} from '@libs/OnboardingUtils';
import Parser from '@libs/Parser';
import {getParsedMessageWithShortMentions} from '@libs/ParsingUtils';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
Expand Down Expand Up @@ -4415,52 +4414,27 @@ function completeOnboarding({
selfDMCreatedReportActionID: selfDMParameters.createdReportActionID,
};

const willRedirectToOldDotFromOnboarding = shouldOnboardingRedirectToOldDot(companySize, userReportedIntegration);
if (willRedirectToOldDotFromOnboarding) {
// We should only set testDriveModalDismissed to false if it's not already true (i.e., if the modal hasn't been dismissed yet).
if (!shouldSkipTestDriveModal && onboarding?.testDriveModalDismissed !== true) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.NVP_ONBOARDING,
value: {isLoading: true},
value: {testDriveModalDismissed: false},
});

successData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.NVP_ONBOARDING,
value: {isLoading: false},
value: {testDriveModalDismissed: false},
});

failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.NVP_ONBOARDING,
value: {isLoading: false},
value: {testDriveModalDismissed: null},
});
}

// Only add the dismissed state of the test drive modal when the user is not redirected to oldDot,
// because we don't want the modal to reappear when returning from oldDot.
// We should only set testDriveModalDismissed to false if it's not already true (i.e., if the modal hasn't been dismissed yet).
if (!shouldSkipTestDriveModal && !(engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && willRedirectToOldDotFromOnboarding)) {
if (onboarding?.testDriveModalDismissed !== true) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.NVP_ONBOARDING,
value: {testDriveModalDismissed: false},
});

successData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.NVP_ONBOARDING,
value: {testDriveModalDismissed: false},
});

failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.NVP_ONBOARDING,
value: {testDriveModalDismissed: null},
});
}
}

API.write(WRITE_COMMANDS.COMPLETE_GUIDED_SETUP, parameters, {optimisticData, successData, failureData});
}

Expand Down
27 changes: 0 additions & 27 deletions src/pages/OnboardingAccounting/BaseOnboardingAccounting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,15 @@ import ScrollView from '@components/ScrollView';
import type {ListItem} from '@components/SelectionListWithSections/types';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
import usePrevious from '@hooks/usePrevious';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {openOldDotLink} from '@libs/actions/Link';
import {setOnboardingAdminsChatReportID, setOnboardingPolicyID, setOnboardingUserReportedIntegration} from '@libs/actions/Welcome';
import Navigation from '@libs/Navigation/Navigation';
import {waitForIdle} from '@libs/Network/SequentialQueue';
import {shouldOnboardingRedirectToOldDot} from '@libs/OnboardingUtils';
import {isPaidGroupPolicy, isPolicyAdmin} from '@libs/PolicyUtils';
import variables from '@styles/variables';
import {closeReactNativeApp} from '@userActions/HybridApp';
import CONFIG from '@src/CONFIG';
import type {OnboardingAccounting} from '@src/CONST';
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
Expand Down Expand Up @@ -101,7 +94,6 @@ function BaseOnboardingAccounting({shouldUseNativeStyles, route}: BaseOnboarding
const {onboardingIsMediumOrLargerScreenWidth, isSmallScreenWidth} = useResponsiveLayout();
const [onboardingPolicyID] = useOnyx(ONYXKEYS.ONBOARDING_POLICY_ID, {canBeMissing: true});
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: false});
const [onboardingCompanySize] = useOnyx(ONYXKEYS.ONBOARDING_COMPANY_SIZE, {canBeMissing: true});
const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false});
const [onboardingUserReportedIntegration] = useOnyx(ONYXKEYS.ONBOARDING_USER_REPORTED_INTEGRATION, {canBeMissing: true});

Expand All @@ -110,9 +102,6 @@ function BaseOnboardingAccounting({shouldUseNativeStyles, route}: BaseOnboarding

const paidGroupPolicy = Object.values(allPolicies ?? {}).find((policy) => isPaidGroupPolicy(policy) && isPolicyAdmin(policy, session?.email));
const [onboarding] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {canBeMissing: true});
const {isOffline} = useNetwork();
const isLoading = onboarding?.isLoading;
const prevIsLoading = usePrevious(isLoading);

const isVsb = onboarding?.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.VSB;

Expand All @@ -125,20 +114,6 @@ function BaseOnboardingAccounting({shouldUseNativeStyles, route}: BaseOnboarding
setOnboardingPolicyID(paidGroupPolicy.id);
}, [paidGroupPolicy, onboardingPolicyID]);

useEffect(() => {
if (!!isLoading || !prevIsLoading) {
return;
}

if (CONFIG.IS_HYBRID_APP) {
closeReactNativeApp({shouldSetNVP: true});
return;
}
waitForIdle().then(() => {
openOldDotLink(CONST.OLDDOT_URLS.INBOX, true);
});
}, [isLoading, prevIsLoading]);

const accountingOptions: OnboardingListItem[] = useMemo(() => {
const createAccountingOption = (integration: Integration): OnboardingListItem => ({
keyForList: integration.key,
Expand Down Expand Up @@ -275,8 +250,6 @@ function BaseOnboardingAccounting({shouldUseNativeStyles, route}: BaseOnboarding
large
text={translate('common.continue')}
onPress={handleContinue}
isLoading={isLoading}
isDisabled={isOffline && shouldOnboardingRedirectToOldDot(onboardingCompanySize, userReportedIntegration)}
pressOnEnter
/>
</FixedFooter>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, {useCallback, useContext, useEffect, useMemo, useState} from 'react';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import {InteractionManager, View} from 'react-native';
import Button from '@components/Button';
import Checkbox from '@components/Checkbox';
import CustomStatusBarAndBackgroundContext from '@components/CustomStatusBarAndBackground/CustomStatusBarAndBackgroundContext';
import FixedFooter from '@components/FixedFooter';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import Icon from '@components/Icon';
Expand All @@ -18,21 +17,15 @@ import useNetwork from '@hooks/useNetwork';
import useOnboardingMessages from '@hooks/useOnboardingMessages';
import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
import usePrevious from '@hooks/usePrevious';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import {openOldDotLink} from '@libs/actions/Link';
import {createWorkspace, generatePolicyID, updateInterestedFeatures} from '@libs/actions/Policy/Policy';
import {completeOnboarding} from '@libs/actions/Report';
import {setOnboardingAdminsChatReportID, setOnboardingPolicyID} from '@libs/actions/Welcome';
import {WRITE_COMMANDS} from '@libs/API/types';
import {navigateAfterOnboardingWithMicrotaskQueue} from '@libs/navigateAfterOnboarding';
import Navigation from '@libs/Navigation/Navigation';
import {waitForIdle} from '@libs/Network/SequentialQueue';
import {shouldOnboardingRedirectToOldDot} from '@libs/OnboardingUtils';
import {isPaidGroupPolicy, isPolicyAdmin} from '@libs/PolicyUtils';
import {closeReactNativeApp} from '@userActions/HybridApp';
import CONFIG from '@src/CONFIG';
import CONST, {FEATURE_IDS} from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
Expand All @@ -43,7 +36,6 @@ function BaseOnboardingInterestedFeatures({shouldUseNativeStyles}: BaseOnboardin
const styles = useThemeStyles();
const {translate} = useLocalize();
const {onboardingMessages} = useOnboardingMessages();
const {setRootStatusBarEnabled} = useContext(CustomStatusBarAndBackgroundContext);
const illustrations = useMemoizedLazyIllustrations(['FolderOpen', 'Accounting', 'CompanyCard', 'Workflows', 'InvoiceBlue', 'Rules', 'Car', 'Tag', 'PerDiem', 'HandCard'] as const);

// We need to use isSmallScreenWidth, see navigateAfterOnboarding function comment
Expand All @@ -61,10 +53,7 @@ function BaseOnboardingInterestedFeatures({shouldUseNativeStyles}: BaseOnboardin
const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false});

const paidGroupPolicy = Object.values(allPolicies ?? {}).find((policy) => isPaidGroupPolicy(policy) && isPolicyAdmin(policy, session?.email));
const [onboarding] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {canBeMissing: true});
const {isOffline} = useNetwork();
const isLoading = onboarding?.isLoading;
const prevIsLoading = usePrevious(isLoading);
const [width, setWidth] = useState(0);

const features: Feature[] = useMemo(() => {
Expand Down Expand Up @@ -149,22 +138,6 @@ function BaseOnboardingInterestedFeatures({shouldUseNativeStyles}: BaseOnboardin
setOnboardingPolicyID(paidGroupPolicy.id);
}, [paidGroupPolicy, onboardingPolicyID]);

useEffect(() => {
if (!!isLoading || !prevIsLoading) {
return;
}

if (CONFIG.IS_HYBRID_APP) {
closeReactNativeApp({shouldSetNVP: true});
setRootStatusBarEnabled(false);
return;
}
// Wait for CompleteGuidedSetup and CreateWorkspace to complete before redirecting to OldDot to prevent showing this onboarding modal again.
waitForIdle().then(() => {
openOldDotLink(CONST.OLDDOT_URLS.INBOX, true);
});
}, [isLoading, prevIsLoading, setRootStatusBarEnabled]);

const handleContinue = useCallback(() => {
if (!onboardingPurposeSelected || !onboardingCompanySize) {
return;
Expand Down Expand Up @@ -217,11 +190,6 @@ function BaseOnboardingInterestedFeatures({shouldUseNativeStyles}: BaseOnboardin
shouldSkipTestDriveModal: !!policyID && !adminsChatReportID,
});

if (shouldOnboardingRedirectToOldDot(onboardingCompanySize, newUserReportedIntegration)) {
// Do not call openOldDotLink here because it will cause a navigation loop. See https://github.com/Expensify/App/issues/61363
return;
}

// Avoid creating new WS because onboardingPolicyID is cleared before unmounting
// eslint-disable-next-line @typescript-eslint/no-deprecated
InteractionManager.runAfterInteractions(() => {
Expand Down Expand Up @@ -374,7 +342,6 @@ function BaseOnboardingInterestedFeatures({shouldUseNativeStyles}: BaseOnboardin
large
text={translate('common.continue')}
onPress={handleContinue}
isLoading={isLoading}
isDisabled={isOffline}
pressOnEnter
/>
Expand Down
Loading