Skip to content
Merged
4 changes: 4 additions & 0 deletions src/components/SettlementButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {isUserValidatedSelector} from '@selectors/Account';
import {hasSeenTourSelector} from '@selectors/Onboarding';
import isEmpty from 'lodash/isEmpty';
import truncate from 'lodash/truncate';
import React, {useCallback, useContext, useMemo} from 'react';
Expand Down Expand Up @@ -152,6 +153,8 @@ function SettlementButton({
const hasIntentToPay = ((formattedPaymentMethods.length === 1 && isIOUReport(iouReport)) || policy?.achAccount?.state === CONST.BANK_ACCOUNT.STATE.OPEN) && !lastPaymentMethod;
const {isBetaEnabled} = usePermissions();
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});

const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
Expand Down Expand Up @@ -368,6 +371,7 @@ function SettlementButton({
activePolicyID,
currentUserAccountIDParam: currentUserPersonalDetails.accountID,
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
isSelfTourViewed,
}).policyID;
};
const addBankAccountItem = {
Expand Down
4 changes: 3 additions & 1 deletion src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {RouteProp} from '@react-navigation/native';
import {useNavigationState} from '@react-navigation/native';
import type {StackCardInterpolationProps} from '@react-navigation/stack';
import {hasSeenTourSelector} from '@selectors/Onboarding';
import React, {memo, useEffect, useRef, useState} from 'react';
import ComposeProviders from '@components/ComposeProviders';
import OpenConfirmNavigateExpensifyClassicModal from '@components/ConfirmNavigateExpensifyClassicModal';
Expand Down Expand Up @@ -178,6 +179,7 @@ function AuthScreens() {
const [initialLastUpdateIDAppliedToClient] = useOnyx(ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT);
const [modal] = useOnyx(ONYXKEYS.MODAL);
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});

const [lastUpdateIDAppliedToClient] = useOnyx(ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT);
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP);
Expand Down Expand Up @@ -280,7 +282,7 @@ function AuthScreens() {
App.reconnectApp(initialLastUpdateIDAppliedToClient);
}

App.setUpPoliciesAndNavigate(session, introSelected, activePolicyID);
App.setUpPoliciesAndNavigate(session, introSelected, activePolicyID, isSelfTourViewed);

Download.clearDownloads();

Expand Down
14 changes: 13 additions & 1 deletion src/libs/actions/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ function getMissingOnyxUpdates(updateIDFrom = 0, updateIDTo: number | string = 0
}

type CreateWorkspaceWithPolicyDraftParams = {
isSelfTourViewed: boolean | undefined;
introSelected: OnyxEntry<OnyxTypes.IntroSelected>;
policyOwnerEmail?: string;
policyName?: string;
Expand Down Expand Up @@ -573,6 +574,7 @@ function createWorkspaceWithPolicyDraftAndNavigateToIt(params: CreateWorkspaceWi
currentUserAccountIDParam,
currentUserEmailParam,
shouldCreateControlPolicy,
isSelfTourViewed,
} = params;

const policyIDWithDefault = policyID || generatePolicyID();
Expand All @@ -597,12 +599,14 @@ function createWorkspaceWithPolicyDraftAndNavigateToIt(params: CreateWorkspaceWi
currentUserEmailParam,
allReportsParam: allReports,
shouldCreateControlPolicy,
isSelfTourViewed,
});
Navigation.navigate(routeToNavigate, {forceReplace: !transitionFromOldDot});
});
}

type SavePolicyDraftByNewWorkspaceParams = {
isSelfTourViewed: boolean | undefined;
policyID?: string;
policyName?: string;
policyOwnerEmail?: string;
Expand Down Expand Up @@ -635,6 +639,7 @@ function savePolicyDraftByNewWorkspace({
currentUserEmailParam,
allReportsParam,
shouldCreateControlPolicy,
isSelfTourViewed,
}: SavePolicyDraftByNewWorkspaceParams) {
createWorkspace({
policyOwnerEmail,
Expand All @@ -651,6 +656,7 @@ function savePolicyDraftByNewWorkspace({
currentUserEmailParam,
allReportsParam,
shouldCreateControlPolicy,
isSelfTourViewed,
});
}

Expand All @@ -669,7 +675,12 @@ function savePolicyDraftByNewWorkspace({
* When the exitTo route is 'workspace/new', we create a new
* workspace and navigate to it
*/
function setUpPoliciesAndNavigate(session: OnyxEntry<OnyxTypes.Session>, introSelected: OnyxEntry<OnyxTypes.IntroSelected>, activePolicyID: string | undefined) {
function setUpPoliciesAndNavigate(
session: OnyxEntry<OnyxTypes.Session>,
introSelected: OnyxEntry<OnyxTypes.IntroSelected>,
activePolicyID: string | undefined,
isSelfTourViewed: boolean | undefined,
) {
const currentUrl = getCurrentUrl();
if (!session || !currentUrl?.includes('exitTo')) {
return;
Expand Down Expand Up @@ -699,6 +710,7 @@ function setUpPoliciesAndNavigate(session: OnyxEntry<OnyxTypes.Session>, introSe
activePolicyID,
currentUserAccountIDParam: currentSessionData.accountID ?? CONST.DEFAULT_NUMBER_ID,
currentUserEmailParam: currentSessionData.email ?? '',
isSelfTourViewed,
});
return;
}
Expand Down
11 changes: 10 additions & 1 deletion src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@
onboardingPurposeSelected?: OnboardingPurpose;
shouldAddGuideWelcomeMessage?: boolean;
shouldCreateControlPolicy?: boolean;
// TODO: Make it required once we complete refactoring the buildPolicyData function to use isSelfTourViewed. Refactor issue: https://github.com/Expensify/App/issues/66424
isSelfTourViewed?: boolean;
};

// TODO: Remove this type once we complete refactoring the buildPolicyData function to use isSelfTourViewed. Refactor issue: https://github.com/Expensify/App/issues/66424
type CreateWorkspaceDataOptions = Omit<BuildPolicyDataOptions, 'isSelfTourViewed'> & {
isSelfTourViewed: boolean | undefined;
};

type DuplicatePolicyDataOptions = {
Expand Down Expand Up @@ -226,7 +233,7 @@
};

const deprecatedAllPolicies: OnyxCollection<Policy> = {};
Onyx.connect({

Check warning on line 236 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
callback: (val, key) => {
if (!key) {
Expand All @@ -242,7 +249,7 @@
});

let deprecatedAllReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 252 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand All @@ -252,7 +259,7 @@

let deprecatedSessionEmail = '';
let deprecatedSessionAccountID = 0;
Onyx.connect({

Check warning on line 262 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (val) => {
deprecatedSessionEmail = val?.email ?? '';
Expand All @@ -261,7 +268,7 @@
});

let deprecatedAllPersonalDetails: OnyxEntry<PersonalDetailsList>;
Onyx.connect({

Check warning on line 271 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (val) => (deprecatedAllPersonalDetails = val),
});
Expand Down Expand Up @@ -2291,6 +2298,7 @@
shouldAddGuideWelcomeMessage = true,
onboardingPurposeSelected,
shouldCreateControlPolicy = false,
isSelfTourViewed,
} = options;
const workspaceName = policyName || generateDefaultWorkspaceName(policyOwnerEmail);

Expand Down Expand Up @@ -2721,6 +2729,7 @@
onboardingPolicyID: policyID,
onboardingPurposeSelected,
companySize: companySize ?? (introSelected?.companySize as OnboardingCompanySize),
isSelfTourViewed,
});
if (!onboardingData) {
return {successData, optimisticData, failureData, params};
Expand Down Expand Up @@ -2765,7 +2774,7 @@
return {successData, optimisticData, failureData, params};
}

function createWorkspace(options: BuildPolicyDataOptions): CreateWorkspaceParams {
function createWorkspace(options: CreateWorkspaceDataOptions): CreateWorkspaceParams {
// Set default engagement choice if not provided
const optionsWithDefaults = {
engagementChoice: CONST.ONBOARDING_CHOICES.MANAGE_TEAM,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {hasSeenTourSelector} from '@selectors/Onboarding';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import {InteractionManager, View} from 'react-native';
import Button from '@components/Button';
Expand Down Expand Up @@ -52,6 +53,8 @@ function BaseOnboardingInterestedFeatures({shouldUseNativeStyles}: BaseOnboardin
const [userReportedIntegration] = useOnyx(ONYXKEYS.ONBOARDING_USER_REPORTED_INTEGRATION);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});

const {isBetaEnabled} = usePermissions();
const [session] = useOnyx(ONYXKEYS.SESSION);
const [conciergeReportID = ''] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
Expand Down Expand Up @@ -199,6 +202,7 @@ function BaseOnboardingInterestedFeatures({shouldUseNativeStyles}: BaseOnboardin
currentUserAccountIDParam: currentUserPersonalDetails.accountID,
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
shouldAddGuideWelcomeMessage: false,
isSelfTourViewed,
})
: {adminsChatReportID: onboardingAdminsChatReportID, policyID: onboardingPolicyID};

Expand Down Expand Up @@ -267,6 +271,7 @@ function BaseOnboardingInterestedFeatures({shouldUseNativeStyles}: BaseOnboardin
currentUserPersonalDetails.accountID,
currentUserPersonalDetails.email,
introSelected,
isSelfTourViewed,
conciergeReportID,
]);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {hasSeenTourSelector} from '@selectors/Onboarding';
import React, {useCallback, useEffect} from 'react';
import {View} from 'react-native';
import FormProvider from '@components/Form/FormProvider';
Expand Down Expand Up @@ -39,6 +40,8 @@ function BaseOnboardingWorkspaceConfirmation({shouldUseNativeStyles}: BaseOnboar
const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout();
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});

const {inputCallbackRef} = useAutoFocusInput();

const [draftValues, draftValuesMetadata] = useOnyx(ONYXKEYS.FORMS.ONBOARDING_WORKSPACE_DETAILS_FORM_DRAFT);
Expand Down Expand Up @@ -80,6 +83,7 @@ function BaseOnboardingWorkspaceConfirmation({shouldUseNativeStyles}: BaseOnboar
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
shouldAddGuideWelcomeMessage: false,
onboardingPurposeSelected,
isSelfTourViewed,
})
: {adminsChatReportID: onboardingAdminsChatReportID, policyID: onboardingPolicyID};

Expand All @@ -99,6 +103,7 @@ function BaseOnboardingWorkspaceConfirmation({shouldUseNativeStyles}: BaseOnboar
currentUserPersonalDetails.accountID,
currentUserPersonalDetails.email,
introSelected,
isSelfTourViewed,
],
);

Expand Down
4 changes: 4 additions & 0 deletions src/pages/Travel/WorkspaceConfirmationForTravelPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {StackScreenProps} from '@react-navigation/stack';
import {hasSeenTourSelector} from '@selectors/Onboarding';
import React from 'react';
import ScreenWrapper from '@components/ScreenWrapper';
import WorkspaceConfirmationForm from '@components/WorkspaceConfirmationForm';
Expand All @@ -17,6 +18,8 @@ type WorkspaceConfirmationForTravelPageProps = StackScreenProps<TravelNavigatorP
function WorkspaceConfirmationForTravelPage({route}: WorkspaceConfirmationForTravelPageProps) {
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});

const currentUserPersonalDetails = useCurrentUserPersonalDetails();

const goBack = () => {
Expand All @@ -37,6 +40,7 @@ function WorkspaceConfirmationForTravelPage({route}: WorkspaceConfirmationForTra
activePolicyID,
currentUserAccountIDParam: currentUserPersonalDetails.accountID,
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
isSelfTourViewed,
});
goBack();
};
Expand Down
4 changes: 4 additions & 0 deletions src/pages/iou/request/step/IOURequestStepUpgrade.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {hasSeenTourSelector} from '@selectors/Onboarding';
import React, {useRef, useState} from 'react';
import ConfirmModal from '@components/ConfirmModal';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
Expand Down Expand Up @@ -59,6 +60,7 @@ function IOURequestStepUpgrade({
const {isRestrictedPolicyCreation} = usePreferredPolicy();
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});

const feature = Object.values(CONST.UPGRADE_FEATURE_INTRO_MAPPING)
.filter((value) => value.id !== CONST.UPGRADE_FEATURE_INTRO_MAPPING.policyPreventMemberChangingTitle.id)
Expand Down Expand Up @@ -157,6 +159,7 @@ function IOURequestStepUpgrade({
currentUserAccountIDParam: currentUserPersonalDetails.accountID,
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
onboardingPurposeSelected,
isSelfTourViewed,
});
setIsUpgraded(true);
policyDataRef.current = policyData;
Expand All @@ -182,6 +185,7 @@ function IOURequestStepUpgrade({
currentUserAccountIDParam: currentUserPersonalDetails.accountID,
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
onboardingPurposeSelected,
isSelfTourViewed,
});
policyDataRef.current = policyData;
setCreatedPolicyName(params.name);
Expand Down
4 changes: 4 additions & 0 deletions src/pages/workspace/WorkspaceConfirmationPage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {hasSeenTourSelector} from '@selectors/Onboarding';
import React from 'react';
import ScreenWrapper from '@components/ScreenWrapper';
import WorkspaceConfirmationForm from '@components/WorkspaceConfirmationForm';
Expand All @@ -22,6 +23,8 @@ function WorkspaceConfirmationPage() {
const [lastPaymentMethod] = useOnyx(ONYXKEYS.NVP_LAST_PAYMENT_METHOD);
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});

const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const privateSubscription = usePrivateSubscription();
const onSubmit = (params: WorkspaceConfirmationSubmitFunctionParams) => {
Expand All @@ -43,6 +46,7 @@ function WorkspaceConfirmationPage() {
currentUserAccountIDParam: currentUserPersonalDetails.accountID,
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
shouldCreateControlPolicy: isSubscriptionTypeOfInvoicing(privateSubscription?.type),
isSelfTourViewed,
});
};
const currentUrl = getCurrentUrl();
Expand Down
Loading
Loading