diff --git a/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormPages.tsx b/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormPages.tsx index 3991418e2ebe..e00f332f5bee 100644 --- a/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormPages.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormPages.tsx @@ -6,11 +6,12 @@ import useOnyx from '@hooks/useOnyx'; import useSubPage from '@hooks/useSubPage'; import type {SubPageProps} from '@hooks/useSubPage/types'; import Navigation from '@libs/Navigation/Navigation'; +import getCurrencyForNonUSDBankAccount from '@pages/ReimbursementAccount/NonUSD/utils/getCurrencyForNonUSDBankAccount'; +import getNeededDocumentsStatusForBeneficialOwner from '@pages/ReimbursementAccount/NonUSD/utils/getNeededDocumentsStatusForBeneficialOwner'; import {clearErrors, setDraftValues} from '@userActions/FormActions'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; import SafeString from '@src/utils/SafeString'; import Address from './BeneficialOwnerDetailsFormSubSteps/Address'; import Confirmation from './BeneficialOwnerDetailsFormSubSteps/Confirmation'; @@ -59,6 +60,8 @@ type BeneficialOwnerDetailsFormPagesProps = { function BeneficialOwnerDetailsFormPages({stepNames, policyID, onFinished, backTo}: BeneficialOwnerDetailsFormPagesProps) { const {translate} = useLocalize(); const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); + const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); + const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); const ownerBeingModifiedID = reimbursementAccountDraft?.ownerBeingModifiedID ?? CONST.NON_USD_BANK_ACCOUNT.CURRENT_USER_KEY; const isUserEnteringHisOwnData = ownerBeingModifiedID === CONST.NON_USD_BANK_ACCOUNT.CURRENT_USER_KEY; @@ -67,7 +70,7 @@ function BeneficialOwnerDetailsFormPages({stepNames, policyID, onFinished, backT const beneficialOwnerNationalityInputID = `${PREFIX}_${ownerBeingModifiedID}_${NATIONALITY}` as const; const beneficialOwnerNationality = SafeString(reimbursementAccountDraft?.[beneficialOwnerNationalityInputID]); - const countryStepCountryValue = reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? ''; + const {country: countryStepCountryValue, currency} = getCurrencyForNonUSDBankAccount(policy, reimbursementAccountDraft, reimbursementAccount); const totalOwnedPercentage = Object.fromEntries( ownerKeys.map((key) => { @@ -81,11 +84,12 @@ function BeneficialOwnerDetailsFormPages({stepNames, policyID, onFinished, backT if (beneficialOwnerNationality !== CONST.COUNTRY.US) { pagesToSkip.push(SUB_PAGE_NAMES.LAST_4_SSN); } - if (countryStepCountryValue === CONST.COUNTRY.GB && beneficialOwnerNationality === CONST.COUNTRY.GB) { + const documentsStatus = getNeededDocumentsStatusForBeneficialOwner(currency, countryStepCountryValue, beneficialOwnerNationality); + if (!documentsStatus.isProofOfOwnershipNeeded && !documentsStatus.isCopyOfIDNeeded && !documentsStatus.isProofOfAddressNeeded && !documentsStatus.isCodiceFiscaleNeeded) { pagesToSkip.push(SUB_PAGE_NAMES.DOCUMENTS); } return pagesToSkip; - }, [beneficialOwnerNationality, countryStepCountryValue]); + }, [beneficialOwnerNationality, countryStepCountryValue, currency]); const buildRoute = useCallback( (pageName: string, action?: 'edit') => ROUTES.BANK_ACCOUNT_NON_USD_SETUP.getRoute({policyID, page: PAGE_NAME.BENEFICIAL_OWNER_INFO, subPage: pageName, action, backTo}),