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
58 changes: 0 additions & 58 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,65 +608,7 @@ const CONST = {
VALIDATION: 'ValidationStep',
ENABLE: 'EnableStep',
},
PAGE_NAMES: {
COUNTRY: 'currency-and-country',
BANK_ACCOUNT: 'bank-info',
REQUESTOR: 'personal-info',
VERIFY_IDENTITY: 'verify-identity',
COMPANY: 'company',
BENEFICIAL_OWNERS: 'business-owner',
ACH_CONTRACT: 'ach-contract',
VALIDATION: 'validation',
ENABLE: 'enable',
},
STEP_NAMES: ['1', '2', '3', '4', '5', '6'],
BANK_INFO_STEP: {
SUB_PAGE_NAMES: {
MANUAL: 'manual',
PLAID: 'plaid',
},
},
PERSONAL_INFO_STEP: {
SUB_PAGE_NAMES: {
FULL_NAME: 'full-name',
DATE_OF_BIRTH: 'date-of-birth',
SSN: 'ssn',
ADDRESS: 'address',
CONFIRMATION: 'confirmation',
},
},
BUSINESS_INFO_STEP: {
SUB_PAGE_NAMES: {
NAME: 'name',
TAX_ID: 'tax-id',
WEBSITE: 'website',
PHONE: 'phone',
ADDRESS: 'address',
TYPE: 'type',
INCORPORATION_DATE: 'start-date',
INCORPORATION_STATE: 'state',
INCORPORATION_CODE: 'code',
CONFIRMATION: 'confirmation',
},
},
BENEFICIAL_OWNERS_STEP: {
SUB_PAGE_NAMES: {
IS_USER_UBO: 'is-user-ubo',
IS_ANYONE_ELSE_UBO: 'is-anyone-else-ubo',
ARE_THERE_MORE_UBOS: 'are-there-more-ubos',
UBOS_LIST: 'ubos-list',
LEGAL_NAME: 'legal-name',
DATE_OF_BIRTH: 'date-of-birth',
SSN: 'ssn',
ADDRESS: 'address',
CONFIRMATION: 'confirmation',
},
},
COMPLETE_VERIFICATION_STEP: {
SUB_PAGE_NAMES: {
CONFIRM_AGREEMENTS: 'confirm-agreements',
},
},
SUBSTEP: {
MANUAL: 'manual',
PLAID: 'plaid',
Expand Down
38 changes: 19 additions & 19 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {ReplacementReason} from './libs/actions/Card';
import type {IOURequestType} from './libs/actions/IOU';
import Log from './libs/Log';
import type {RootNavigatorParamList} from './libs/Navigation/types';
import type {ReimbursementAccountStepToOpen} from './libs/ReimbursementAccountUtils';
import StringUtils from './libs/StringUtils';
import {getUrlWithParams} from './libs/Url';
import SCREENS from './SCREENS';
Expand Down Expand Up @@ -408,24 +409,36 @@ const ROUTES = {
// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
getRoute: (policyID?: string, backTo?: string) => getUrlWithBackToParam(`bank-account/${VERIFY_ACCOUNT}?policyID=${policyID}`, backTo),
},
BANK_ACCOUNT_NEW: 'bank-account/new',
BANK_ACCOUNT_PERSONAL: 'bank-account/personal',
// TODO: rename the route as no longer accepts step
BANK_ACCOUNT_WITH_STEP_TO_OPEN: {
route: 'bank-account/new',
getRoute: ({policyID, bankAccountID, backTo}: {policyID: string | undefined; bankAccountID?: number; backTo?: string}) => {
route: 'bank-account/:stepToOpen?',
getRoute: ({
policyID,
stepToOpen = '',
bankAccountID,
backTo,
subStepToOpen,
}: {
policyID: string | undefined;
stepToOpen?: ReimbursementAccountStepToOpen;
bankAccountID?: number;
backTo?: string;
subStepToOpen?: typeof CONST.BANK_ACCOUNT.STEP.COUNTRY;
}) => {
if (!policyID && !bankAccountID) {
// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
return getUrlWithBackToParam(`bank-account/new`, backTo);
return getUrlWithBackToParam(`bank-account/${stepToOpen}`, backTo);
}

if (bankAccountID) {
// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
return getUrlWithBackToParam(`bank-account/new?bankAccountID=${bankAccountID}`, backTo);
return getUrlWithBackToParam(`bank-account/${stepToOpen}?bankAccountID=${bankAccountID}`, backTo);
}
// TODO this backTo comes from drilling it through bank account form screens
// should be removed once https://github.com/Expensify/App/pull/72219 is resolved
// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
return getUrlWithBackToParam(`bank-account/new?policyID=${policyID}`, backTo);
return getUrlWithBackToParam(`bank-account/${stepToOpen}?policyID=${policyID}${subStepToOpen ? `&subStep=${subStepToOpen}` : ''}`, backTo);
},
},
BANK_ACCOUNT_ENTER_SIGNER_INFO: {
Expand Down Expand Up @@ -457,19 +470,6 @@ const ROUTES = {
return getUrlWithBackToParam(`${base}${pagePart}${subPagePart}${actionPart}${queryString}`, backTo);
},
},
BANK_ACCOUNT_USD_SETUP: {
route: 'bank-account/new/us/:page?/:subPage?/:action?',
// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
getRoute: ({policyID, page, subPage, action, backTo}: {policyID?: string; page?: string; subPage?: string; action?: 'edit'; backTo?: string}) => {
const base = 'bank-account/new/us';
const pagePart = page ? `/${page}` : '';
const subPagePart = subPage ? `/${subPage}` : '';
const actionPart = action ? `/${action}` : '';
const queryString = policyID ? `?policyID=${policyID}` : '';
// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
return getUrlWithBackToParam(`${base}${pagePart}${subPagePart}${actionPart}${queryString}`, backTo);
},
},
SETTINGS: 'settings',
SETTINGS_PROFILE: {
route: 'settings/profile',
Expand Down
1 change: 0 additions & 1 deletion src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,6 @@ const SCREENS = {
},
DYNAMIC_FLAG_COMMENT: 'Dynamic_Flag_Comment',
REIMBURSEMENT_ACCOUNT: 'ReimbursementAccount',
REIMBURSEMENT_ACCOUNT_USD: 'Reimbursement_Account_USD',
REIMBURSEMENT_ACCOUNT_NON_USD: 'Reimbursement_Account_Non_USD',
REIMBURSEMENT_ACCOUNT_ENTER_SIGNER_INFO: 'Reimbursement_Account_Signer_Info',
REFERRAL_DETAILS: 'Referral_Details',
Expand Down
6 changes: 5 additions & 1 deletion src/components/Navigation/DebugTabView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import {getRouteForCurrentStep as getReimbursementAccountRouteForCurrentStep} from '@libs/ReimbursementAccountUtils';
import type {BrickRoad} from '@libs/WorkspacesSettingsUtils';
import {getChatTabBrickRoadReportID} from '@libs/WorkspacesSettingsUtils';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -81,7 +82,10 @@ function getSettingsRoute(status: IndicatorStatus | undefined, reimbursementAcco
case CONST.INDICATOR_STATUS.HAS_POLICY_ERRORS:
return ROUTES.WORKSPACE_INITIAL.getRoute(policyIDWithErrors);
case CONST.INDICATOR_STATUS.HAS_REIMBURSEMENT_ACCOUNT_ERRORS:
return ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute({policyID: reimbursementAccount?.achData?.policyID});
return ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute({
policyID: reimbursementAccount?.achData?.policyID,
stepToOpen: getReimbursementAccountRouteForCurrentStep(reimbursementAccount?.achData?.currentStep ?? CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT),
});
case CONST.INDICATOR_STATUS.HAS_SUBSCRIPTION_ERRORS:
return ROUTES.SETTINGS_SUBSCRIPTION.route;
case CONST.INDICATOR_STATUS.HAS_SUBSCRIPTION_INFO:
Expand Down
28 changes: 0 additions & 28 deletions src/hooks/useReimbursementAccountSubmitCallback.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,6 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
[SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_ITEMS]: () => require<ReactComponentModule>('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopItemsPage').default,
[SCREENS.CONNECT_EXISTING_BUSINESS_BANK_ACCOUNT_ROOT]: () => require<ReactComponentModule>('@pages/workspace/ConnectExistingBusinessBankAccountPage').default,
[SCREENS.REIMBURSEMENT_ACCOUNT]: () => require<ReactComponentModule>('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default,
[SCREENS.REIMBURSEMENT_ACCOUNT_USD]: () => require<ReactComponentModule>('../../../../pages/ReimbursementAccount/USD/USDVerifiedBankAccountFlowPage').default,
[SCREENS.REIMBURSEMENT_ACCOUNT_NON_USD]: () => require<ReactComponentModule>('../../../../pages/ReimbursementAccount/NonUSD/NonUSDVerifiedBankAccountFlowPage').default,
[SCREENS.REIMBURSEMENT_ACCOUNT_VERIFY_ACCOUNT]: () => require<ReactComponentModule>('../../../../pages/ReimbursementAccount/ReimbursementAccountVerifyAccountPage').default,
[SCREENS.REIMBURSEMENT_ACCOUNT_ENTER_SIGNER_INFO]: () => require<ReactComponentModule>('../../../../pages/ReimbursementAccount/EnterSignerInfo').default,
Expand Down
4 changes: 0 additions & 4 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1169,10 +1169,6 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
path: ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.route,
exact: true,
},
[SCREENS.REIMBURSEMENT_ACCOUNT_USD]: {
path: ROUTES.BANK_ACCOUNT_USD_SETUP.route,
exact: true,
},
[SCREENS.REIMBURSEMENT_ACCOUNT_NON_USD]: {
path: ROUTES.BANK_ACCOUNT_NON_USD_SETUP.route,
exact: true,
Expand Down
8 changes: 0 additions & 8 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2268,14 +2268,6 @@ type ReimbursementAccountNavigatorParamList = {
bankAccountID?: string;
subStep?: typeof CONST.BANK_ACCOUNT.STEP.COUNTRY;
};
[SCREENS.REIMBURSEMENT_ACCOUNT_USD]: {
page?: string;
subPage?: string;
action?: 'edit';
policyID?: string;
// eslint-disable-next-line no-restricted-syntax -- backTo is a temporary param will be removed after https://github.com/Expensify/App/issues/73825 is done
backTo?: Routes;
};
[SCREENS.REIMBURSEMENT_ACCOUNT_NON_USD]: {
page?: string;
subPage?: string;
Expand Down
25 changes: 23 additions & 2 deletions src/libs/ReimbursementAccountUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {ValueOf} from 'type-fest';
import CONST from '@src/CONST';
import type {ACHDataReimbursementAccount} from '@src/types/onyx/ReimbursementAccount';
import type {ACHDataReimbursementAccount, ReimbursementAccountStep} from '@src/types/onyx/ReimbursementAccount';

type ReimbursementAccountStepToOpen = ValueOf<typeof REIMBURSEMENT_ACCOUNT_ROUTE_NAMES> | '';

Expand All @@ -14,6 +14,27 @@ const REIMBURSEMENT_ACCOUNT_ROUTE_NAMES = {
NEW: 'new',
} as const;

function getRouteForCurrentStep(currentStep: ReimbursementAccountStep): ReimbursementAccountStepToOpen {
switch (currentStep) {
case CONST.BANK_ACCOUNT.STEP.COMPANY:
return REIMBURSEMENT_ACCOUNT_ROUTE_NAMES.COMPANY;
case CONST.BANK_ACCOUNT.STEP.REQUESTOR:
return REIMBURSEMENT_ACCOUNT_ROUTE_NAMES.PERSONAL_INFORMATION;
case CONST.BANK_ACCOUNT.STEP.BENEFICIAL_OWNERS:
return REIMBURSEMENT_ACCOUNT_ROUTE_NAMES.BENEFICIAL_OWNERS;
case CONST.BANK_ACCOUNT.STEP.ACH_CONTRACT:
return REIMBURSEMENT_ACCOUNT_ROUTE_NAMES.CONTRACT;
case CONST.BANK_ACCOUNT.STEP.VALIDATION:
return REIMBURSEMENT_ACCOUNT_ROUTE_NAMES.VALIDATE;
case CONST.BANK_ACCOUNT.STEP.ENABLE:
return REIMBURSEMENT_ACCOUNT_ROUTE_NAMES.ENABLE;
case CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT:
case CONST.BANK_ACCOUNT.STEP.COUNTRY:
default:
return REIMBURSEMENT_ACCOUNT_ROUTE_NAMES.NEW;
}
}

/**
* Returns true if a VBBA exists in any state other than OPEN or LOCKED
*/
Expand Down Expand Up @@ -46,5 +67,5 @@ const hasInProgressVBBA = (achData?: ACHDataReimbursementAccount, isNonUSDWorksp
return hasInProgressUSDVBBA(achData);
};

export {getBankAccountIDAsNumber, hasInProgressUSDVBBA, hasInProgressNonUSDVBBA, hasInProgressVBBA, REIMBURSEMENT_ACCOUNT_ROUTE_NAMES};
export {getBankAccountIDAsNumber, getRouteForCurrentStep, hasInProgressUSDVBBA, hasInProgressNonUSDVBBA, hasInProgressVBBA, REIMBURSEMENT_ACCOUNT_ROUTE_NAMES};
export type {ReimbursementAccountStepToOpen};
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ type ConnectedVerifiedBankAccountProps = {
onBackButtonPress: () => void;

/** Method to set the state of shouldShowConnectedVerifiedBankAccount */
setShouldShowConnectedVerifiedBankAccount?: (shouldShowConnectedVerifiedBankAccount: boolean) => void;
setShouldShowConnectedVerifiedBankAccount: (shouldShowConnectedVerifiedBankAccount: boolean) => void;

/** Method to set the state of USD bank account step */
setUSDBankAccountStep?: (step: string | null) => void;
setUSDBankAccountStep: (step: string | null) => void;

/** Whether the workspace currency is set to non USD currency */
isNonUSDWorkspace: boolean;
Expand Down
40 changes: 26 additions & 14 deletions src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import type {ReimbursementAccountNavigatorParamList} from '@libs/Navigation/types';
import {goBackFromInvalidPolicy, isPendingDeletePolicy, isPolicyAdmin} from '@libs/PolicyUtils';
import {hasInProgressUSDVBBA, hasInProgressVBBA} from '@libs/ReimbursementAccountUtils';
import {getRouteForCurrentStep, hasInProgressUSDVBBA, hasInProgressVBBA} from '@libs/ReimbursementAccountUtils';
import shouldReopenOnfido from '@libs/shouldReopenOnfido';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
import {isFullScreenName} from '@navigation/helpers/isNavigatorName';
Expand Down Expand Up @@ -60,6 +60,7 @@ import {isEmptyObject} from '@src/types/utils/EmptyObject';
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';
import ConnectedVerifiedBankAccount from './ConnectedVerifiedBankAccount';
import getStartPageForContinueSetup from './NonUSD/utils/getStartPageForContinueSetup';
import USDVerifiedBankAccountFlow from './USD/USDVerifiedBankAccountFlow';
import getFieldsForStep from './USD/utils/getFieldsForStep';
import getStepToOpenFromRouteParams from './USD/utils/getStepToOpenFromRouteParams';
import VerifiedBankAccountFlowEntryPoint from './VerifiedBankAccountFlowEntryPoint';
Expand All @@ -76,7 +77,7 @@ const OFFLINE_ACCESSIBLE_STEPS = [
CONST.BANK_ACCOUNT.STEP.ACH_CONTRACT,
] as const;

function ReimbursementAccountPage({route, policy, isLoadingPolicy}: ReimbursementAccountPageProps) {
function ReimbursementAccountPage({route, policy, isLoadingPolicy, navigation}: ReimbursementAccountPageProps) {
const {environmentURL} = useEnvironment();
const session = useSession();
const [reimbursementAccount, reimbursementAccountMetadata] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT);
Expand Down Expand Up @@ -332,6 +333,12 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen
// so we don't clear it. We only want to clear the errors if we are moving between steps.
hideBankAccountErrors();
}

// Use the current page navigation object to set the param to the correct route in the stack
const stepToOpen = getRouteForCurrentStep(currentStep);
if (stepToOpen && !isNonUSDSetup) {
navigation.setParams({stepToOpen});
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[
Expand All @@ -350,19 +357,10 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen
// If user comes back to the flow we never want to allow him to go through plaid again
// so we're always showing manual setup with locked numbers he can not change
setBankAccountSubStep(CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL).then(() => {
const stepToPageName: Record<string, string> = {
[CONST.BANK_ACCOUNT.STEP.COUNTRY]: CONST.BANK_ACCOUNT.PAGE_NAMES.COUNTRY,
[CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT]: CONST.BANK_ACCOUNT.PAGE_NAMES.BANK_ACCOUNT,
[CONST.BANK_ACCOUNT.STEP.REQUESTOR]: CONST.BANK_ACCOUNT.PAGE_NAMES.REQUESTOR,
[CONST.BANK_ACCOUNT.STEP.COMPANY]: CONST.BANK_ACCOUNT.PAGE_NAMES.COMPANY,
[CONST.BANK_ACCOUNT.STEP.BENEFICIAL_OWNERS]: CONST.BANK_ACCOUNT.PAGE_NAMES.BENEFICIAL_OWNERS,
[CONST.BANK_ACCOUNT.STEP.ACH_CONTRACT]: CONST.BANK_ACCOUNT.PAGE_NAMES.ACH_CONTRACT,
[CONST.BANK_ACCOUNT.STEP.VALIDATION]: CONST.BANK_ACCOUNT.PAGE_NAMES.VALIDATION,
};
const page = stepToPageName[currentStep] ?? CONST.BANK_ACCOUNT.PAGE_NAMES.COUNTRY;
Navigation.navigate(ROUTES.BANK_ACCOUNT_USD_SETUP.getRoute({policyID: policyIDParam, page, backTo}));
setShouldShowContinueSetupButton(false);
setUSDBankAccountStep(currentStep);
});
}, [currentStep, policyIDParam, backTo]);
}, [currentStep]);

const continueNonUSDVBBASetup = () => {
const {page: startPage, subPage: startSubPage} = getStartPageForContinueSetup(achData, nonUSDCountryDraftValue, policyCurrency, reimbursementAccountDraft);
Expand Down Expand Up @@ -532,6 +530,20 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen
);
}

if (!isNonUSDSetup && USDBankAccountStep !== null) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor step-specific bank-account routes in USD flow

The inline USD flow is now gated behind USDBankAccountStep !== null, but USDBankAccountStep is not derived from stepToOpen route params. As a result, step-targeted links generated via BANK_ACCOUNT_WITH_STEP_TO_OPEN (for example bank-account/company?...) can resolve to the entry point instead of opening the requested step, so direct navigation to the failing reimbursement step no longer works.

Useful? React with 👍 / 👎.

return (
<USDVerifiedBankAccountFlow
USDBankAccountStep={USDBankAccountStep}
policyID={policyIDParam}
onBackButtonPress={goBack}
requestorStepRef={requestorStepRef}
onfidoToken={onfidoToken}
setUSDBankAccountStep={setUSDBankAccountStep}
setShouldShowConnectedVerifiedBankAccount={setShouldShowConnectedVerifiedBankAccount}
/>
);
}

return (
<VerifiedBankAccountFlowEntryPoint
setShouldShowContinueSetupButton={setShouldShowContinueSetupButton}
Expand Down
Loading
Loading