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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type {OnboardingCompanySize} from '@src/CONST';

type SwitchToOldDotOnCompanySizeParams = {
onboardingCompanySize: OnboardingCompanySize;
};

export default SwitchToOldDotOnCompanySizeParams;
1 change: 1 addition & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,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';
Expand Down
2 changes: 2 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,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',
Expand Down Expand Up @@ -675,6 +676,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;
Expand Down
29 changes: 27 additions & 2 deletions src/libs/actions/Welcome/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import * as API from '@libs/API';
import {SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
import DateUtils from '@libs/DateUtils';
import Log from '@libs/Log';
import CONST from '@src/CONST';
import type {OnboardingCompanySize} from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {OnboardingPurpose} from '@src/types/onyx';
import type Onboarding from '@src/types/onyx/Onboarding';
import type TryNewDot from '@src/types/onyx/TryNewDot';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import * as OnboardingFlow from './OnboardingFlow';
import {clearInitialPath} from './OnboardingFlow';

type OnboardingData = Onboarding | undefined;

Expand Down Expand Up @@ -149,6 +150,29 @@ function completeHybridAppOnboarding() {
});
}

/*
* Decides whether we should set dismissed key to `true` or `false` based on company size
*/
function switchToOldDotOnNonMicroCompanySize(onboardingCompanySize: 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});
}

Onyx.connect({
key: ONYXKEYS.NVP_ONBOARDING,
callback: (value) => {
Expand Down Expand Up @@ -183,7 +207,7 @@ function resetAllChecks() {
});
isLoadingReportData = true;
isOnboardingInProgress = false;
OnboardingFlow.clearInitialPath();
clearInitialPath();
}

function setSelfTourViewed(shouldUpdateOnyxDataOnlyLocally = false) {
Expand Down Expand Up @@ -230,6 +254,7 @@ export {
setOnboardingAdminsChatReportID,
setOnboardingPolicyID,
completeHybridAppOnboarding,
switchToOldDotOnNonMicroCompanySize,
setOnboardingErrorMessage,
setOnboardingCompanySize,
setSelfTourViewed,
Expand Down
21 changes: 16 additions & 5 deletions src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import getPlatform from '@libs/getPlatform';
import Navigation from '@libs/Navigation/Navigation';
import {isPaidGroupPolicy} from '@libs/PolicyUtils';
import {openOldDotLink} from '@userActions/Link';
import {createWorkspace, generatePolicyID} from '@userActions/Policy/Policy';
import {completeOnboarding} from '@userActions/Report';
import {setOnboardingAdminsChatReportID, setOnboardingCompanySize, setOnboardingPolicyID} from '@userActions/Welcome';
import {setOnboardingAdminsChatReportID, setOnboardingCompanySize, setOnboardingPolicyID, switchToOldDotOnNonMicroCompanySize} from '@userActions/Welcome';
import CONST from '@src/CONST';
import type {OnboardingCompanySize} from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -73,6 +75,11 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE
}
setOnboardingCompanySize(selectedCompanySize);

// Redirect is disabled on desktop
if (getPlatform() !== CONST.PLATFORM.DESKTOP) {
switchToOldDotOnNonMicroCompanySize(selectedCompanySize);
}
Comment thread
mateuuszzzzz marked this conversation as resolved.

const shouldCreateWorkspace = !onboardingPolicyID && !paidGroupPolicy;

// We need `adminsChatReportID` for `completeOnboarding`, but at the same time, we don't want to call `createWorkspace` more than once.
Expand All @@ -86,8 +93,8 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE
setOnboardingPolicyID(policyID);
}

// For MICRO companies (1-10 employees), we want to remain on NewDot.
if (!NativeModules.HybridAppModule || selectedCompanySize === CONST.ONBOARDING_COMPANY_SIZE.MICRO) {
// For MICRO companies (1-10 employees) or desktop app, we want to remain on NewDot.
if (selectedCompanySize === CONST.ONBOARDING_COMPANY_SIZE.MICRO || getPlatform() === CONST.PLATFORM.DESKTOP) {
Navigation.navigate(ROUTES.ONBOARDING_ACCOUNTING.getRoute(route.params?.backTo));
return;
}
Expand All @@ -107,8 +114,12 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE
);
}

NativeModules.HybridAppModule.closeReactNativeApp(false, true);
setRootStatusBarEnabled(false);
if (NativeModules.HybridAppModule) {
NativeModules.HybridAppModule.closeReactNativeApp(false, true);
setRootStatusBarEnabled(false);
} else {
openOldDotLink(CONST.OLDDOT_URLS.INBOX, true);
}
}}
pressOnEnter
/>
Expand Down