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
3 changes: 3 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8861,6 +8861,9 @@ const CONST = {
INTERACTIVE_STEP_SUB_HEADER: {
STEP_BUTTON: 'InteractiveStepSubHeader-StepButton',
},
REIMBURSEMENT_ACCOUNT: {
YOUR_DATA_IS_SECURE: 'ReimbursementAccount-YourDataIsSecure',
},
SOCIALS: {
LINK: 'Socials',
},
Expand Down
12 changes: 8 additions & 4 deletions src/components/SubStepForms/CountryFullStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,19 @@ function CountryFullStep({onBackButtonPress, stepNames, onSubmit, policyID, isCo
const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT);
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);

const currency = reimbursementAccountDraft?.currency ?? policy?.outputCurrency ?? '';
const currency =
reimbursementAccountDraft?.currency ??
policy?.outputCurrency ??
reimbursementAccount?.achData?.currency ??
CONST.BBA_COUNTRY_CURRENCY_MAP[reimbursementAccount?.achData?.country ?? ''];

const shouldAllowChange = currency === CONST.CURRENCY.EUR;
const shouldAllowChange = currency === CONST.CURRENCY.EUR && !reimbursementAccount?.achData?.accountNumber;
const defaultCountries = shouldAllowChange ? CONST.ALL_EUROPEAN_UNION_COUNTRIES : CONST.ALL_COUNTRIES;
const currencyMappedToCountry = mapCurrencyToCountry(currency);
const countryDefaultValue = reimbursementAccountDraft?.[COUNTRY] ?? reimbursementAccount?.achData?.[COUNTRY] ?? '';
const currencyMappedToCountry = mapCurrencyToCountry(currency) || countryDefaultValue;
const isUkEuCurrencySupported = useExpensifyCardUkEuSupported(policyID) && isComingFromExpensifyCard;
const countriesSupportedForExpensifyCard = getAvailableEuCountries();

const countryDefaultValue = reimbursementAccountDraft?.[COUNTRY] ?? reimbursementAccount?.achData?.[COUNTRY] ?? '';
const [userSelectedCountry, setUserSelectedCountry] = useState<string>(countryDefaultValue);
const selectedCountry = shouldAllowChange ? userSelectedCountry : currencyMappedToCountry;
const disableSubmit = !(currency in CONST.CURRENCY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ function Confirmation({onNext, onMove, isEditing, policyID}: ConfirmationProps)

const [enterSignerInfoForm] = useOnyx(ONYXKEYS.FORMS.ENTER_SINGER_INFO_FORM);
const [enterSignerInfoFormDraft] = useOnyx(ONYXKEYS.FORMS.ENTER_SINGER_INFO_FORM_DRAFT);
const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT);

const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const currency = policy?.outputCurrency ?? '';
const country = mapCurrencyToCountry(currency);
const currency = policy?.outputCurrency ?? reimbursementAccountDraft?.currency ?? '';
const country = mapCurrencyToCountry(currency) ?? reimbursementAccountDraft?.country;
const isDocumentNeededStatus = getNeededDocumentsStatusForSignerInfo(currency, country);
const copyOfID = enterSignerInfoFormDraft?.[INPUT_IDS.SIGNER_COPY_OF_ID] ?? [];
const addressProof = enterSignerInfoFormDraft?.[INPUT_IDS.SIGNER_ADDRESS_PROOF] ?? [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ function UploadDocuments({onNext, isEditing, policyID}: UploadDocumentsProps) {
const styles = useThemeStyles();

const [enterSignerInfoFormDraft] = useOnyx(ONYXKEYS.FORMS.ENTER_SINGER_INFO_FORM_DRAFT);
const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT);
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const [environmentUrl, setEnvironmentUrl] = useState<string | null>(null);

const currency = policy?.outputCurrency ?? '';
const country = mapCurrencyToCountry(currency);
const currency = policy?.outputCurrency ?? reimbursementAccountDraft?.currency ?? '';
const country = mapCurrencyToCountry(currency) ?? reimbursementAccountDraft?.country;
const isDocumentNeededStatus = getNeededDocumentsStatusForSignerInfo(currency, country);
const isPDSandFSGDownloaded = enterSignerInfoFormDraft?.[INPUT_IDS.DOWNLOADED_PDS_AND_FSG] ?? false;
const [isPDSandFSGDownloadedTouched, setIsPDSandFSGDownloadedTouched] = useState<boolean>(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function BankInfo({onBackButtonPress, onSubmit, policyID, stepNames}: BankInfoPr
const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT);
const [corpayFields] = useOnyx(ONYXKEYS.CORPAY_FIELDS);
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const currency = policy?.outputCurrency ?? '';
const currency = policy?.outputCurrency ?? reimbursementAccountDraft?.currency ?? '';
const country = reimbursementAccountDraft?.[COUNTRY] ?? reimbursementAccount?.achData?.[COUNTRY] ?? '';
const inputKeys = getInputKeysForBankInfoStep(corpayFields);
const values = useMemo(() => getBankInfoStepValues(inputKeys, reimbursementAccountDraft, reimbursementAccount), [inputKeys, reimbursementAccount, reimbursementAccountDraft]);
Expand Down Expand Up @@ -106,6 +106,7 @@ function BankInfo({onBackButtonPress, onSubmit, policyID, stepNames}: BankInfoPr
prevScreen,
moveTo,
goToTheLastStep,
// eslint-disable-next-line @typescript-eslint/no-deprecated
} = useSubStep<BankInfoSubStepProps>({bodyContent, startFrom, onFinished: submit});

const handleBackButtonPress = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Confirmation({onNext, onMove, isEditing, ownerBeingModifiedID}: Confirm
const beneficialOwnerNationality = SafeString(reimbursementAccountDraft?.[beneficialOwnerNationalityInputID]);
const policyID = reimbursementAccount?.achData?.policyID;
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const currency = policy?.outputCurrency ?? '';
const currency = policy?.outputCurrency ?? reimbursementAccountDraft?.currency ?? '';
const countryStepCountryValue = reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? '';
const isDocumentNeededStatus = getNeededDocumentsStatusForBeneficialOwner(currency, countryStepCountryValue, beneficialOwnerNationality);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function Documents({onNext, isEditing, ownerBeingModifiedID}: DocumentsProps) {
const countryStepCountryValue = reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? '';
const policyID = reimbursementAccount?.achData?.policyID;
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const currency = policy?.outputCurrency ?? '';
const currency = policy?.outputCurrency ?? reimbursementAccountDraft?.currency ?? '';
const proofOfOwnershipInputID = `${PREFIX}_${ownerBeingModifiedID}_${PROOF_OF_OWNERSHIP}` as const;
const copyOfIDInputID = `${PREFIX}_${ownerBeingModifiedID}_${COPY_OF_ID}` as const;
const addressProofInputID = `${PREFIX}_${ownerBeingModifiedID}_${ADDRESS_PROOF}` as const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function BusinessInfo({onBackButtonPress, onSubmit, stepNames}: BusinessInfoProp
const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT);
const policyID = reimbursementAccount?.achData?.policyID;
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const currency = policy?.outputCurrency ?? '';
const currency = policy?.outputCurrency ?? reimbursementAccountDraft?.currency ?? '';
const businessInfoStepValues = useMemo(() => getSubStepValues(INPUT_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]);
const bankAccountID = reimbursementAccount?.achData?.bankAccountID ?? CONST.DEFAULT_NUMBER_ID;

Expand Down Expand Up @@ -129,6 +129,7 @@ function BusinessInfo({onBackButtonPress, onSubmit, stepNames}: BusinessInfoProp
};
}, [reimbursementAccount?.errors, reimbursementAccount?.isSavingCorpayOnboardingCompanyFields, reimbursementAccount?.isSuccess, onSubmit]);

// eslint-disable-next-line @typescript-eslint/no-deprecated
const {componentToRender: SubStep, isEditing, screenIndex, nextScreen, prevScreen, moveTo, goToTheLastStep} = useSubStep({bodyContent, startFrom, onFinished: submit});

const handleBackButtonPress = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ const STEP_FIELDS = [TRADE_VOLUME];
function AverageReimbursement({onNext, onMove, isEditing}: AverageReimbursementProps) {
const {translate} = useLocalize();
const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT);
const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT);
const [corpayOnboardingFields] = useOnyx(ONYXKEYS.CORPAY_ONBOARDING_FIELDS);
const policyID = reimbursementAccount?.achData?.policyID;
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const currency = policy?.outputCurrency ?? '';
const currency = policy?.outputCurrency ?? reimbursementAccountDraft?.currency ?? '';

const tradeVolumeRangeListOptions = useMemo(
() => getListOptionsFromCorpayPicklist(corpayOnboardingFields?.picklists.TradeVolumeRange),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ const STEP_FIELDS = [ANNUAL_VOLUME];
function PaymentVolume({onNext, onMove, isEditing}: PaymentVolumeProps) {
const {translate} = useLocalize();
const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT);
const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT);
const [corpayOnboardingFields] = useOnyx(ONYXKEYS.CORPAY_ONBOARDING_FIELDS);
const policyID = reimbursementAccount?.achData?.policyID;
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const currency = policy?.outputCurrency ?? '';
const currency = policy?.outputCurrency ?? reimbursementAccountDraft?.currency ?? '';

const annualVolumeRangeListOptions = useMemo(
() => getListOptionsFromCorpayPicklist(corpayOnboardingFields?.picklists.AnnualVolumeRange),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ function Website({onNext, onMove, isEditing}: WebsiteProps) {
const [session] = useOnyx(ONYXKEYS.SESSION);
const [account] = useOnyx(ONYXKEYS.ACCOUNT);
const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT);
const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT);
const policyID = reimbursementAccount?.achData?.policyID;
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const currency = policy?.outputCurrency ?? '';
const currency = policy?.outputCurrency ?? reimbursementAccountDraft?.currency ?? '';
const isWebsiteRequired = currency === CONST.CURRENCY.USD || CONST.CURRENCY.CAD;

const defaultWebsiteExample = useMemo(() => getDefaultCompanyWebsite(session, account, true), [session, account]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ function EnterEmail({onSubmit, isUserDirector, isLoading}: EnterEmailProps) {
const {inputCallbackRef} = useAutoFocusInput();

const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT);
const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT);
const policyID = reimbursementAccount?.achData?.policyID;
const policy = usePolicy(policyID);
const currency = policy?.outputCurrency ?? '';
const currency = policy?.outputCurrency ?? reimbursementAccountDraft?.currency ?? '';
const shouldGatherBothEmails = currency === CONST.CURRENCY.AUD && !isUserDirector;
const shouldGatherOnlySecondSignerEmail = currency === CONST.CURRENCY.AUD && isUserDirector;
const companyName = reimbursementAccount?.achData?.corpay?.[COMPANY_NAME] ?? '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function SignerInfo({onBackButtonPress, onSubmit, stepNames}: SignerInfoProps) {
const [account] = useOnyx(ONYXKEYS.ACCOUNT);
const policyID = reimbursementAccount?.achData?.policyID;
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const currency = policy?.outputCurrency ?? '';
const currency = policy?.outputCurrency ?? reimbursementAccountDraft?.currency ?? '';
const isUserOwner = reimbursementAccount?.achData?.corpay?.[OWNS_MORE_THAN_25_PERCENT] ?? reimbursementAccountDraft?.[OWNS_MORE_THAN_25_PERCENT] ?? false;
const companyName = reimbursementAccount?.achData?.corpay?.[COMPANY_NAME] ?? reimbursementAccountDraft?.[COMPANY_NAME] ?? '';
const savedSignerEmail = reimbursementAccount?.achData?.corpay?.[SIGNER_EMAIL];
Expand Down Expand Up @@ -134,6 +134,7 @@ function SignerInfo({onBackButtonPress, onSubmit, stepNames}: SignerInfoProps) {
prevScreen,
moveTo,
goToTheLastStep,
// eslint-disable-next-line @typescript-eslint/no-deprecated
} = useSubStep<SignerDetailsFormProps>({bodyContent, startFrom: 0, onFinished: submit});

const handleNextSubStep = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function Confirmation({onNext, onMove, isEditing}: ConfirmationProps) {

const policyID = reimbursementAccount?.achData?.policyID;
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const currency = policy?.outputCurrency ?? '';
const currency = policy?.outputCurrency ?? reimbursementAccountDraft?.currency ?? '';
const countryStepCountryValue = reimbursementAccount?.achData?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? '';
const isDocumentNeededStatus = getNeededDocumentsStatusForSignerInfo(currency, countryStepCountryValue);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function UploadDocuments({onNext, isEditing}: UploadDocumentsProps) {
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const [environmentUrl, setEnvironmentUrl] = useState<string | null>(null);

const currency = policy?.outputCurrency ?? '';
const currency = policy?.outputCurrency ?? reimbursementAccountDraft?.currency ?? '';
const countryStepCountryValue = reimbursementAccount?.achData?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? '';
const isDocumentNeededStatus = getNeededDocumentsStatusForSignerInfo(currency, countryStepCountryValue);
const isPDSandFSGDownloaded = reimbursementAccount?.achData?.corpay?.downloadedPDSandFSG ?? reimbursementAccountDraft?.[signerInfoKeys.DOWNLOADED_PDS_AND_FSG] ?? false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useCallback, useEffect} from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import Icon from '@components/Icon';
Expand All @@ -13,6 +13,7 @@ import ScrollView from '@components/ScrollView';
import Section from '@components/Section';
import Text from '@components/Text';
import TextLink from '@components/TextLink';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
Expand All @@ -21,6 +22,7 @@ import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {getLatestError, getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils';
import Navigation from '@libs/Navigation/Navigation';
import {hasActiveAdminWorkspaces} from '@libs/PolicyUtils';
import WorkspaceResetBankAccountModal from '@pages/workspace/WorkspaceResetBankAccountModal';
import {goToWithdrawalAccountSetupStep, openPlaidView, updateReimbursementAccountDraft} from '@userActions/BankAccounts';
import {openExternalLink} from '@userActions/Link';
Expand Down Expand Up @@ -98,6 +100,10 @@ function VerifiedBankAccountFlowEntryPoint({
const [reimbursementAccountOptionPressed] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT_OPTION_PRESSED);
const isAccountValidated = account?.validated ?? false;

const {login: currentUserLogin} = useCurrentUserPersonalDetails();
const isCurrentUserPolicyAdminSelector = (policies: OnyxCollection<OnyxTypes.Policy>) => hasActiveAdminWorkspaces(currentUserLogin, policies);
const [isCurrentUserPolicyAdmin] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {selector: isCurrentUserPolicyAdminSelector});

const personalBankAccounts = bankAccountList ? Object.keys(bankAccountList).filter((key) => bankAccountList[key].accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT) : [];

const removeExistingBankAccountDetails = () => {
Expand Down Expand Up @@ -182,6 +188,14 @@ function VerifiedBankAccountFlowEntryPoint({
prepareNextStep(CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID);
};

const navigateAfterReset = () => {
// we want to navigate after reset if the user comes from settings/wallet or settings/wallet/bank-account-purpose
if (!backTo.includes(ROUTES.SETTINGS_WALLET)) {
return;
}
Navigation.goBack(isCurrentUserPolicyAdmin ? ROUTES.SETTINGS_BANK_ACCOUNT_PURPOSE : ROUTES.SETTINGS_WALLET);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean that if user is not an admin, resetting the flow will close RHP and open wallet page?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, because non-admin should not have access to the purpose page

};

return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand Down Expand Up @@ -298,6 +312,7 @@ function VerifiedBankAccountFlowEntryPoint({
setNonUSDBankAccountStep={setNonUSDBankAccountStep}
setShouldShowContinueSetupButton={setShouldShowContinueSetupButton}
setIsResettingBankAccount={setIsResettingBankAccount}
navigateAfterReset={navigateAfterReset}
/>
)}
</ScreenWrapper>
Expand Down
7 changes: 7 additions & 0 deletions src/pages/workspace/WorkspaceResetBankAccountModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ type WorkspaceResetBankAccountModalProps = {

/** Method to set the state of isResettingBankAccount */
setIsResettingBankAccount?: (isResetting: boolean) => void;

/** Method to navigate after resetting bank account */
navigateAfterReset?: () => void;
};

function WorkspaceResetBankAccountModal({
Expand All @@ -42,6 +45,7 @@ function WorkspaceResetBankAccountModal({
isNonUSDWorkspace,
setShouldShowContinueSetupButton,
setIsResettingBankAccount,
navigateAfterReset,
}: WorkspaceResetBankAccountModalProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand Down Expand Up @@ -103,6 +107,9 @@ function WorkspaceResetBankAccountModal({
setUSDBankAccountStep(null);
}
}
if (navigateAfterReset) {
navigateAfterReset();
}
};

return (
Expand Down
Loading