Skip to content
Closed
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
6 changes: 3 additions & 3 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ const ONYXKEYS = {
/** A list of policies that a user can join */
JOINABLE_POLICIES: 'joinablePolicies',

/* Contains meta data for the call to the API to get the joinable policies */
VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES: 'validateUserAndGetAccessiblePolicies',
/** Flag to indicate if the joinablePolicies are loading */
JOINABLE_POLICIES_LOADING: 'joinablePoliciesLoading',

/** Information about the current session (authToken, accountID, email, loading, error) */
SESSION: 'session',
Expand Down Expand Up @@ -1011,7 +1011,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.PENDING_CONTACT_ACTION]: OnyxTypes.PendingContactAction;
[ONYXKEYS.VALIDATE_ACTION_CODE]: OnyxTypes.ValidateMagicCodeAction;
[ONYXKEYS.JOINABLE_POLICIES]: OnyxTypes.JoinablePolicies;
[ONYXKEYS.VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES]: OnyxTypes.ValidateUserAndGetAccessiblePolicies;
[ONYXKEYS.JOINABLE_POLICIES_LOADING]: boolean;
[ONYXKEYS.SESSION]: OnyxTypes.Session;
[ONYXKEYS.USER_METADATA]: OnyxTypes.UserMetadata;
[ONYXKEYS.STASHED_SESSION]: OnyxTypes.Session;
Expand Down
6 changes: 1 addition & 5 deletions src/components/MagicCodeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ type MagicCodeInputProps = {

/** TestID for test */
testID?: string;

/** Whether to allow auto submit again after the previous attempt fails */
allowResubmit?: boolean;
};

type MagicCodeInputHandle = {
Expand Down Expand Up @@ -108,7 +105,6 @@ function MagicCodeInput(
autoComplete,
hasError = false,
testID = '',
allowResubmit = false,
}: MagicCodeInputProps,
ref: ForwardedRef<MagicCodeInputHandle>,
) {
Expand Down Expand Up @@ -179,7 +175,7 @@ function MagicCodeInput(
const validateAndSubmit = () => {
const numbers = decomposeString(value, maxLength);
// eslint-disable-next-line @typescript-eslint/no-use-before-define
if ((wasSubmitted && !allowResubmit) || !shouldSubmitOnComplete || numbers.filter((n) => isNumeric(n)).length !== maxLength || isOffline) {
if (wasSubmitted || !shouldSubmitOnComplete || numbers.filter((n) => isNumeric(n)).length !== maxLength || isOffline) {
return;
}
if (!wasSubmitted) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ type ValidateCodeFormProps = {
/** Whether the form is loading or not */
isLoading?: boolean;

/** Whether to allow auto submit again after the previous attempt fails */
allowResubmit?: boolean;

/** Whether to show skip button */
shouldShowSkipButton?: boolean;

Expand All @@ -104,7 +101,6 @@ function BaseValidateCodeForm({
hideSubmitButton,
submitButtonText,
isLoading,
allowResubmit,
shouldShowSkipButton = false,
handleSkipButtonPress,
}: ValidateCodeFormProps) {
Expand Down Expand Up @@ -271,7 +267,6 @@ function BaseValidateCodeForm({
hasError={canShowError && !isEmptyObject(finalValidateError)}
onFulfill={validateAndSubmitForm}
autoFocus={false}
allowResubmit={allowResubmit}
/>
{shouldShowTimer && (
<Text style={[styles.mt5]}>
Expand Down
16 changes: 9 additions & 7 deletions src/hooks/useOnboardingFlow.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {useEffect} from 'react';
import {InteractionManager} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import {isUserOnPrivateDomain} from '@libs/actions/Session';
import {startOnboardingFlow} from '@libs/actions/Welcome/OnboardingFlow';
import Navigation from '@libs/Navigation/Navigation';
import {hasCompletedGuidedSetupFlowSelector, tryNewDotOnyxSelector} from '@libs/onboardingSelectors';
Expand All @@ -17,20 +18,20 @@
* Warning: This hook should be used only once in the app
*/
function useOnboardingFlowRouter() {
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {initialValue: true, canBeMissing: true});
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {initialValue: true});

Check failure on line 21 in src/hooks/useOnboardingFlow.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

useOnyx() calls require you to pass the "canBeMissing" param
const [isOnboardingCompleted, isOnboardingCompletedMetadata] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {

Check failure on line 22 in src/hooks/useOnboardingFlow.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

useOnyx() calls require you to pass the "canBeMissing" param
selector: hasCompletedGuidedSetupFlowSelector,
canBeMissing: true,
});
const [tryNewDot, tryNewDotdMetadata] = useOnyx(ONYXKEYS.NVP_TRYNEWDOT, {

Check failure on line 25 in src/hooks/useOnboardingFlow.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

useOnyx() calls require you to pass the "canBeMissing" param
selector: tryNewDotOnyxSelector,
canBeMissing: true,
});
const {isHybridAppOnboardingCompleted, hasBeenAddedToNudgeMigration} = tryNewDot ?? {};

const [dismissedProductTraining, dismissedProductTrainingMetadata] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {canBeMissing: true});
const [dismissedProductTraining, dismissedProductTrainingMetadata] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING);

Check failure on line 30 in src/hooks/useOnboardingFlow.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

useOnyx() calls require you to pass the "canBeMissing" param

const [isSingleNewDotEntry, isSingleNewDotEntryMetadata] = useOnyx(ONYXKEYS.IS_SINGLE_NEW_DOT_ENTRY, {canBeMissing: true});
const isPrivateDomain = isUserOnPrivateDomain();

const [isSingleNewDotEntry, isSingleNewDotEntryMetadata] = useOnyx(ONYXKEYS.IS_SINGLE_NEW_DOT_ENTRY);

Check failure on line 34 in src/hooks/useOnboardingFlow.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

useOnyx() calls require you to pass the "canBeMissing" param
useEffect(() => {
// This should delay opening the onboarding modal so it does not interfere with the ongoing ReportScreen params changes
InteractionManager.runAfterInteractions(() => {
Expand Down Expand Up @@ -71,13 +72,13 @@
// But if the hybrid app onboarding is completed, but NewDot onboarding is not completed, we start NewDot onboarding flow
// 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) {
startOnboardingFlow();
startOnboardingFlow(isPrivateDomain);
}
}

// 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) {
startOnboardingFlow();
startOnboardingFlow(isPrivateDomain);
}
});
}, [
Expand All @@ -92,6 +93,7 @@
dismissedProductTrainingMetadata,
dismissedProductTraining?.migratedUserWelcomeModal,
dismissedProductTraining,
isPrivateDomain,
]);

return {isOnboardingCompleted, isHybridAppOnboardingCompleted};
Expand Down
5 changes: 0 additions & 5 deletions src/libs/API/parameters/AskToJoinPolicyParams.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/libs/API/parameters/JoinPolicyInviteLink.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type JoinPolicyInviteLinkParams = {
policyID: string;
inviterEmail?: string;
inviterEmail: string;
};

export default JoinPolicyInviteLinkParams;
1 change: 0 additions & 1 deletion src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ export type {default as TogglePlatformMuteParams} from './TogglePlatformMutePara
export type {default as GetCorpayBankAccountFieldsParams} from './GetCorpayBankAccountFieldsParams';
export type {default as BankAccountCreateCorpayParams} from './BankAccountCreateCorpayParams';
export type {default as JoinAccessiblePolicyParams} from './JoinAccessiblePolicyParams';
export type {default as AskToJoinPolicyParams} from './AskToJoinPolicyParams';
export type {default as ImportPerDiemRatesParams} from './ImportPerDiemRatesParams';
export type {default as ExportPerDiemCSVParams} from './ExportPerDiemCSVParams';
export type {default as ExportReportPDFParams} from './ExportReportPDFParams';
Expand Down
5 changes: 0 additions & 5 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ const WRITE_COMMANDS = {
SET_POLICY_CUSTOM_TAX_NAME: 'SetPolicyCustomTaxName',
JOIN_POLICY_VIA_INVITE_LINK: 'JoinWorkspaceViaInviteLink',
JOIN_ACCESSIBLE_POLICY: 'JoinAccessiblePolicy',
ASK_TO_JOIN_POLICY: 'AskToJoinPolicy',
ACCEPT_JOIN_REQUEST: 'AcceptJoinRequest',
DECLINE_JOIN_REQUEST: 'DeclineJoinRequest',
CREATE_POLICY_TAX: 'CreatePolicyTax',
Expand Down Expand Up @@ -458,7 +457,6 @@ const WRITE_COMMANDS = {
GET_CORPAY_BANK_ACCOUNT_FIELDS: 'GetCorpayBankAccountFields',
BANK_ACCOUNT_CREATE_CORPAY: 'BankAccount_CreateCorpay',
UPDATE_WORKSPACE_CUSTOM_UNIT: 'UpdateWorkspaceCustomUnit',
GET_ACCESSIBLE_POLICIES: 'GetAccessibleDomainPoliciesForOnyx',
VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES: 'ValidateUserAndGetAccessiblePolicies',
DISMISS_PRODUCT_TRAINING: 'DismissProductTraining',
GET_VALIDATE_CODE_FOR_ACCOUNT_MERGE: 'GetValidateCodeForAccountMerge',
Expand Down Expand Up @@ -715,7 +713,6 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.SEARCH]: Parameters.SearchParams;
[WRITE_COMMANDS.SET_POLICY_CATEGORY_TAX]: Parameters.SetPolicyCategoryTaxParams;
[WRITE_COMMANDS.JOIN_POLICY_VIA_INVITE_LINK]: Parameters.JoinPolicyInviteLinkParams;
[WRITE_COMMANDS.GET_ACCESSIBLE_POLICIES]: null;
[WRITE_COMMANDS.VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES]: Parameters.ValidateUserAndGetAccessiblePoliciesParams;
[WRITE_COMMANDS.ACCEPT_JOIN_REQUEST]: Parameters.AcceptJoinRequestParams;
[WRITE_COMMANDS.DECLINE_JOIN_REQUEST]: Parameters.DeclineJoinRequestParams;
Expand Down Expand Up @@ -952,8 +949,6 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.UPDATE_INVOICE_COMPANY_WEBSITE]: Parameters.UpdateInvoiceCompanyWebsiteParams;

[WRITE_COMMANDS.JOIN_ACCESSIBLE_POLICY]: Parameters.JoinAccessiblePolicyParams;
[WRITE_COMMANDS.ASK_TO_JOIN_POLICY]: Parameters.AskToJoinPolicyParams;

// Dismis Product Training
[WRITE_COMMANDS.DISMISS_PRODUCT_TRAINING]: Parameters.DismissProductTrainingParams;
[WRITE_COMMANDS.ADD_WORK_EMAIL]: Parameters.AddWorkEmailParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ function OnboardingModalNavigator() {
const styles = useThemeStyles();
const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout();
const outerViewRef = React.useRef<View>(null);
const [user] = useOnyx(ONYXKEYS.USER, {canBeMissing: true});

const isOnPrivateDomainAndHasAccessiblePolicies = !user?.isFromPublicDomain && user?.hasAccessibleDomainPolicies;

const [accountID] = useOnyx(ONYXKEYS.SESSION, {
selector: (session) => session?.accountID ?? CONST.DEFAULT_NUMBER_ID,
canBeMissing: false,
canBeMissing: true,
});

// Publish a sign_up event when we start the onboarding flow. This should track basic sign ups
Expand Down Expand Up @@ -77,14 +73,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}
/>
)}
<Stack.Screen
name={SCREENS.ONBOARDING.PURPOSE}
component={OnboardingPurpose}
/>
<Stack.Screen
name={SCREENS.ONBOARDING.PERSONAL_DETAILS}
component={OnboardingPersonalDetails}
Expand All @@ -105,14 +97,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}
Expand Down
12 changes: 6 additions & 6 deletions src/libs/Navigation/NavigationRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import {hasCompletedGuidedSetupFlowSelector, wasInvitedToNewDotSelector} from '@libs/onboardingSelectors';
import {getPathFromURL} from '@libs/Url';
import {updateLastVisitedPath} from '@userActions/App';
import * as Session from '@userActions/Session';
import {updateOnboardingLastVisitedPath} from '@userActions/Welcome';
import {getOnboardingInitialPath} from '@userActions/Welcome/OnboardingFlow';
import CONFIG from '@src/CONFIG';
Expand Down Expand Up @@ -91,18 +92,17 @@

const currentReportIDValue = useCurrentReportID();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const [user] = useOnyx(ONYXKEYS.USER, {canBeMissing: true});
const [user] = useOnyx(ONYXKEYS.USER);

Check failure on line 95 in src/libs/Navigation/NavigationRoot.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

useOnyx() calls require you to pass the "canBeMissing" param
const isPrivateDomain = Session.isUserOnPrivateDomain();

const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
const [account] = useOnyx(ONYXKEYS.ACCOUNT);

Check failure on line 98 in src/libs/Navigation/NavigationRoot.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

useOnyx() calls require you to pass the "canBeMissing" param
const [isOnboardingCompleted = true] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {

Check failure on line 99 in src/libs/Navigation/NavigationRoot.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

useOnyx() calls require you to pass the "canBeMissing" param
selector: hasCompletedGuidedSetupFlowSelector,
canBeMissing: true,
});
const [wasInvitedToNewDot = false] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {

Check failure on line 102 in src/libs/Navigation/NavigationRoot.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

useOnyx() calls require you to pass the "canBeMissing" param
selector: wasInvitedToNewDotSelector,
canBeMissing: true,
});
const [hasNonPersonalPolicy] = useOnyx(ONYXKEYS.HAS_NON_PERSONAL_POLICY, {canBeMissing: true});
const [hasNonPersonalPolicy] = useOnyx(ONYXKEYS.HAS_NON_PERSONAL_POLICY);

Check failure on line 105 in src/libs/Navigation/NavigationRoot.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

useOnyx() calls require you to pass the "canBeMissing" param

const previousAuthenticated = usePrevious(authenticated);

Expand All @@ -126,7 +126,7 @@
// 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(isPrivateDomain), linkingConfig.config);
}

// If there is no lastVisitedPath, we can do early return. We won't modify the default behavior.
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Navigation/helpers/getAdaptedStateFromPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function getOnboardingAdaptedState(state: PartialState<NavigationState>): Partia
}

const routes = [];
routes.push({name: onboardingRoute.name === SCREENS.ONBOARDING.WORKSPACES ? SCREENS.ONBOARDING.PERSONAL_DETAILS : SCREENS.ONBOARDING.PURPOSE});
routes.push({name: SCREENS.ONBOARDING.PURPOSE});
if (onboardingRoute.name === SCREENS.ONBOARDING.ACCOUNTING) {
routes.push({name: SCREENS.ONBOARDING.EMPLOYEES});
}
Expand Down
28 changes: 1 addition & 27 deletions src/libs/actions/Policy/Member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ function importPolicyMembers(policyID: string, members: PolicyMember[]) {
* Invite member to the specified policyID
* Please see https://github.com/Expensify/App/blob/main/README.md#Security for more details
*/
function inviteMemberToWorkspace(policyID: string, inviterEmail?: string) {
function inviteMemberToWorkspace(policyID: string, inviterEmail: string) {
const memberJoinKey = `${ONYXKEYS.COLLECTION.POLICY_JOIN_MEMBER}${policyID}` as const;

const optimisticMembersState = {policyID, inviterEmail};
Expand Down Expand Up @@ -1023,31 +1023,6 @@ function joinAccessiblePolicy(policyID: string) {
API.write(WRITE_COMMANDS.JOIN_ACCESSIBLE_POLICY, {policyID}, {optimisticData, failureData});
}

/**
* Ask the policy admin to add member to the selected private domain workspace based on policyID
*/
function askToJoinPolicy(policyID: string) {
const memberJoinKey = `${ONYXKEYS.COLLECTION.POLICY_JOIN_MEMBER}${policyID}` as const;

const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: memberJoinKey,
value: {policyID},
},
];

const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: memberJoinKey,
value: {policyID, errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.people.error.genericAdd')},
},
];

API.write(WRITE_COMMANDS.ASK_TO_JOIN_POLICY, {policyID}, {optimisticData, failureData});
}

/**
* Removes an error after trying to delete a member
*/
Expand Down Expand Up @@ -1260,7 +1235,6 @@ export {
setWorkspaceInviteMembersDraft,
inviteMemberToWorkspace,
joinAccessiblePolicy,
askToJoinPolicy,
acceptJoinRequest,
declineJoinRequest,
isApprover,
Expand Down
50 changes: 0 additions & 50 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5050,54 +5050,6 @@ function getAssignedSupportData(policyID: string) {
API.read(READ_COMMANDS.GET_ASSIGNED_SUPPORT_DATA, parameters);
}

/**
* Validates user account and returns a list of accessible policies.
*/
function getAccessiblePolicies(validateCode?: string) {
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES,
value: {
loading: true,
errors: null,
},
},
];

const successData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES,
value: {
loading: false,
errors: null,
},
},
];

const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES,
value: {
loading: false,
},
},
];

const command = validateCode ? WRITE_COMMANDS.VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES : WRITE_COMMANDS.GET_ACCESSIBLE_POLICIES;

API.write(command, validateCode ? {validateCode} : null, {optimisticData, successData, failureData});
}

/**
* Clear the errors from the get accessible policies request
*/
function clearGetAccessiblePoliciesErrors() {
Onyx.merge(ONYXKEYS.VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES, {errors: null});
}

/**
* Call the API to calculate the bill for the new dot
*/
Expand Down Expand Up @@ -5269,8 +5221,6 @@ export {
updateDefaultPolicy,
getAssignedSupportData,
downgradeToTeam,
getAccessiblePolicies,
clearGetAccessiblePoliciesErrors,
calculateBillNewDot,
payAndDowngrade,
clearBillingReceiptDetailsErrors,
Expand Down
Loading
Loading