From 7e6ae9f0bcd8031eeaac537aca7e1fa6582807d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Muzyk?= Date: Tue, 4 Mar 2025 18:07:33 +0100 Subject: [PATCH 1/8] feat: Step 6 logic --- ...FinishCorpayBankAccountOnboardingParams.ts | 6 +++ src/libs/API/parameters/index.ts | 1 + src/libs/API/types.ts | 2 + src/libs/actions/BankAccounts.ts | 45 +++++++++++++++++++ .../NonUSD/Agreements/index.tsx | 22 ++++++++- src/types/onyx/ReimbursementAccount.ts | 9 ++-- 6 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 src/libs/API/parameters/FinishCorpayBankAccountOnboardingParams.ts diff --git a/src/libs/API/parameters/FinishCorpayBankAccountOnboardingParams.ts b/src/libs/API/parameters/FinishCorpayBankAccountOnboardingParams.ts new file mode 100644 index 000000000000..1058aab7e46d --- /dev/null +++ b/src/libs/API/parameters/FinishCorpayBankAccountOnboardingParams.ts @@ -0,0 +1,6 @@ +type FinishCorpayBankAccountOnboardingParams = { + inputs: string; + bankAccountID: number; +}; + +export default FinishCorpayBankAccountOnboardingParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 38ee3ee71053..eb2bc33eef0a 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -378,3 +378,4 @@ export type {default as GetCorpayOnboardingFieldsParams} from './GetCorpayOnboar export type {SaveCorpayOnboardingCompanyDetailsParams} from './SaveCorpayOnboardingCompanyDetailsParams'; export type {default as AcceptSpotnanaTermsParams} from './AcceptSpotnanaTermsParams'; export type {default as SaveCorpayOnboardingBeneficialOwnerParams} from './SaveCorpayOnboardingBeneficialOwnerParams'; +export type {default as FinishCorpayBankAccountOnboardingParams} from './FinishCorpayBankAccountOnboardingParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 03b5103a6491..d10b9bd35564 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -461,6 +461,7 @@ const WRITE_COMMANDS = { RESET_SMS_DELIVERY_FAILURE_STATUS: 'ResetSMSDeliveryFailureStatus', SAVE_CORPAY_ONBOARDING_COMPANY_DETAILS: 'SaveCorpayOnboardingCompanyDetails', SAVE_CORPAY_ONBOARDING_BENEFICIAL_OWNER: 'SaveCorpayOnboardingBeneficialOwner', + FINISH_CORPAY_BANK_ACCOUNT_ONBOARDING: 'FinishCorpayBankAccountOnboarding', } as const; type WriteCommand = ValueOf; @@ -794,6 +795,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.RESET_SMS_DELIVERY_FAILURE_STATUS]: Parameters.ResetSMSDeliveryFailureStatusParams; [WRITE_COMMANDS.SAVE_CORPAY_ONBOARDING_COMPANY_DETAILS]: Parameters.SaveCorpayOnboardingCompanyDetailsParams; [WRITE_COMMANDS.SAVE_CORPAY_ONBOARDING_BENEFICIAL_OWNER]: Parameters.SaveCorpayOnboardingBeneficialOwnerParams; + [WRITE_COMMANDS.FINISH_CORPAY_BANK_ACCOUNT_ONBOARDING]: Parameters.FinishCorpayBankAccountOnboardingParams; [WRITE_COMMANDS.DELETE_MONEY_REQUEST_ON_SEARCH]: Parameters.DeleteMoneyRequestOnSearchParams; [WRITE_COMMANDS.HOLD_MONEY_REQUEST_ON_SEARCH]: Parameters.HoldMoneyRequestOnSearchParams; diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index 33d3ef57fdf9..2a017a2948f9 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -7,6 +7,7 @@ import type { BankAccountHandlePlaidErrorParams, ConnectBankAccountParams, DeletePaymentBankAccountParams, + FinishCorpayBankAccountOnboardingParams, OpenReimbursementAccountPageParams, SaveCorpayOnboardingBeneficialOwnerParams, ValidateBankAccountWithTransactionsParams, @@ -542,6 +543,44 @@ function saveCorpayOnboardingBeneficialOwners(parameters: SaveCorpayOnboardingBe return API.write(WRITE_COMMANDS.SAVE_CORPAY_ONBOARDING_BENEFICIAL_OWNER, parameters, onyxData); } +function finishCorpayBankAccountOnboarding(parameters: FinishCorpayBankAccountOnboardingParams) { + const onyxData: OnyxData = { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + isFinishingCorpayBankAccountOnboarding: true, + errors: null, + }, + }, + ], + successData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + isFinishingCorpayBankAccountOnboarding: false, + isSuccess: true, + }, + }, + ], + failureData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + isFinishingCorpayBankAccountOnboarding: false, + isSuccess: false, + errors: getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), + }, + }, + ], + }; + + return API.write(WRITE_COMMANDS.FINISH_CORPAY_BANK_ACCOUNT_ONBOARDING, parameters, onyxData); +} + function clearReimbursementAccount() { Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, null); } @@ -562,6 +601,10 @@ function clearReimbursementAccountSaveCorpayOnboardingBeneficialOwners() { Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {isSuccess: null, isSavingCorpayOnboardingBeneficialOwnersFields: null}); } +function clearReimbursementAccountFinishCorpayBankAccountOnboarding() { + Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {isSuccess: null, isFinishingCorpayBankAccountOnboarding: null}); +} + /** * Function to display and fetch data for Reimbursement Account step * @param stepToOpen - current step to open @@ -848,6 +891,8 @@ export { saveCorpayOnboardingBeneficialOwners, clearReimbursementAccountSaveCorpayOnboardingBeneficialOwners, clearCorpayBankAccountFields, + finishCorpayBankAccountOnboarding, + clearReimbursementAccountFinishCorpayBankAccountOnboarding, }; export type {BusinessAddress, PersonalAddress}; diff --git a/src/pages/ReimbursementAccount/NonUSD/Agreements/index.tsx b/src/pages/ReimbursementAccount/NonUSD/Agreements/index.tsx index 5cabb20771c8..4565c1a3659b 100644 --- a/src/pages/ReimbursementAccount/NonUSD/Agreements/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/Agreements/index.tsx @@ -1,10 +1,13 @@ import type {ComponentType} from 'react'; -import React from 'react'; +import React, {useEffect} from 'react'; +import {useOnyx} from 'react-native-onyx'; import InteractiveStepWrapper from '@components/InteractiveStepWrapper'; import useLocalize from '@hooks/useLocalize'; import useSubStep from '@hooks/useSubStep'; import type {SubStepProps} from '@hooks/useSubStep/types'; +import {clearReimbursementAccountFinishCorpayBankAccountOnboarding} from '@userActions/BankAccounts'; import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; import Confirmation from './subSteps/Confirmation'; type AgreementsProps = { @@ -19,11 +22,28 @@ const bodyContent: Array> = [Confirmation]; function Agreements({onBackButtonPress, onSubmit}: AgreementsProps) { const {translate} = useLocalize(); + const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); const submit = () => { onSubmit(); }; + useEffect(() => { + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + if (reimbursementAccount?.errors || reimbursementAccount?.isFinishingCorpayBankAccountOnboarding || !reimbursementAccount?.isSuccess) { + return; + } + + if (reimbursementAccount?.isSuccess) { + onSubmit(); + clearReimbursementAccountFinishCorpayBankAccountOnboarding(); + } + + return () => { + clearReimbursementAccountFinishCorpayBankAccountOnboarding(); + }; + }, [reimbursementAccount, onSubmit]); + const {componentToRender: SubStep, isEditing, screenIndex, nextScreen, prevScreen, moveTo, goToTheLastStep} = useSubStep({bodyContent, startFrom: 0, onFinished: submit}); const handleBackButtonPress = () => { diff --git a/src/types/onyx/ReimbursementAccount.ts b/src/types/onyx/ReimbursementAccount.ts index 4ffbe7deeb8a..33abdd2855ba 100644 --- a/src/types/onyx/ReimbursementAccount.ts +++ b/src/types/onyx/ReimbursementAccount.ts @@ -236,15 +236,18 @@ type ReimbursementAccount = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Whether we are loading the data via the API */ isLoading?: boolean; - /** Whether we create corpay bank account */ + /** Whether we create corpay bank account (non USD flow Step 2) */ isCreateCorpayBankAccount?: boolean; - /** Whether we are saving the company data via the API */ + /** Whether we are saving the company data via the API (non USD flow Step 3) */ isSavingCorpayOnboardingCompanyFields?: boolean; - /** Whether we are saving the beneficial owners data via the API */ + /** Whether we are saving the beneficial owners data via the API (non USD flow Step 4) */ isSavingCorpayOnboardingBeneficialOwnersFields?: boolean; + /** Whether we are saving agreements accepted by user via the API (non USD flow Step 6) */ + isFinishingCorpayBankAccountOnboarding?: boolean; + /** Where the request is successful */ isSuccess?: boolean; From 4729594132878f97e9f2d62ef5f72ac6f982de25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Muzyk?= Date: Wed, 5 Mar 2025 13:32:30 +0100 Subject: [PATCH 2/8] feat: submit method --- src/languages/en.ts | 3 ++ src/languages/es.ts | 3 ++ .../NonUSD/Agreements/index.tsx | 26 ++++++++-- .../Agreements/subSteps/Confirmation.tsx | 50 ++++++++++++++----- 4 files changed, 66 insertions(+), 16 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index f2038765525d..652b08e8917d 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2520,9 +2520,12 @@ const translations = { iCertify: 'I certify that the information provided is true and accurate.', termsAndConditions: 'terms and conditions.', accept: 'Accept and add bank account', + iConsentToThe: 'I consent to the', + privacyNotice: 'privacy notice', error: { authorized: 'You must be a controlling officer with authorization to operate the business bank account', certify: 'Please certify that the information is true and accurate', + consent: 'Please consent to the privacy notice', }, }, finishStep: { diff --git a/src/languages/es.ts b/src/languages/es.ts index 4d33e351f3f5..26b27ef2e076 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2544,9 +2544,12 @@ const translations = { iCertify: 'Certifico que la información proporcionada es verdadera y correcta.', termsAndConditions: 'términos y condiciones.', accept: 'Agregar y aceptar cuenta bancaria', + iConsentToThe: 'Doy mi consentimiento para el', + privacyNotice: 'aviso de privacidad', error: { authorized: 'Debe ser un funcionario controlador con autorización para operar la cuenta bancaria comercial', certify: 'Por favor certifique que la información es verdadera y exacta', + consent: 'Por favor, consienta el aviso de privacidad', }, }, finishStep: { diff --git a/src/pages/ReimbursementAccount/NonUSD/Agreements/index.tsx b/src/pages/ReimbursementAccount/NonUSD/Agreements/index.tsx index 4565c1a3659b..3683581b5f23 100644 --- a/src/pages/ReimbursementAccount/NonUSD/Agreements/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/Agreements/index.tsx @@ -1,13 +1,15 @@ import type {ComponentType} from 'react'; -import React, {useEffect} from 'react'; +import React, {useEffect, useMemo} from 'react'; import {useOnyx} from 'react-native-onyx'; import InteractiveStepWrapper from '@components/InteractiveStepWrapper'; import useLocalize from '@hooks/useLocalize'; import useSubStep from '@hooks/useSubStep'; import type {SubStepProps} from '@hooks/useSubStep/types'; -import {clearReimbursementAccountFinishCorpayBankAccountOnboarding} from '@userActions/BankAccounts'; +import getSubStepValues from '@pages/ReimbursementAccount/utils/getSubStepValues'; +import {clearReimbursementAccountFinishCorpayBankAccountOnboarding, finishCorpayBankAccountOnboarding} from '@userActions/BankAccounts'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; import Confirmation from './subSteps/Confirmation'; type AgreementsProps = { @@ -20,12 +22,30 @@ type AgreementsProps = { const bodyContent: Array> = [Confirmation]; +const INPUT_KEYS = { + PROVIDE_TRUTHFUL_INFORMATION: INPUT_IDS.ADDITIONAL_DATA.CORPAY.PROVIDE_TRUTHFUL_INFORMATION, + AGREE_TO_TERMS_AND_CONDITIONS: INPUT_IDS.ADDITIONAL_DATA.CORPAY.AGREE_TO_TERMS_AND_CONDITIONS, + CONSENT_TO_PRIVACY_NOTICE: INPUT_IDS.ADDITIONAL_DATA.CORPAY.CONSENT_TO_PRIVACY_NOTICE, + AUTHORIZED_TO_BIND_CLIENT_TO_AGREEMENT: INPUT_IDS.ADDITIONAL_DATA.CORPAY.AUTHORIZED_TO_BIND_CLIENT_TO_AGREEMENT, +}; + function Agreements({onBackButtonPress, onSubmit}: AgreementsProps) { const {translate} = useLocalize(); const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); + const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); + const agreementsStepValues = useMemo(() => getSubStepValues(INPUT_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); + const bankAccountID = reimbursementAccount?.achData?.bankAccountID ?? CONST.DEFAULT_NUMBER_ID; const submit = () => { - onSubmit(); + finishCorpayBankAccountOnboarding({ + inputs: JSON.stringify({ + provideTruthfulInformation: agreementsStepValues.provideTruthfulInformation, + agreeToTermsAndConditions: agreementsStepValues.agreeToTermsAndConditions, + consentToPrivacyNotice: agreementsStepValues.consentToPrivacyNotice, + authorizedToBindClientToAgreement: agreementsStepValues.authorizedToBindClientToAgreement, + }), + bankAccountID, + }); }; useEffect(() => { diff --git a/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx b/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx index 1e181d42a00f..efa4a165cda3 100644 --- a/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx @@ -1,4 +1,4 @@ -import React, {useCallback} from 'react'; +import React, {useCallback, useMemo} from 'react'; import {useOnyx} from 'react-native-onyx'; import CheckboxWithLabel from '@components/CheckboxWithLabel'; import FormProvider from '@components/Form/FormProvider'; @@ -10,11 +10,12 @@ import useLocalize from '@hooks/useLocalize'; import type {SubStepProps} from '@hooks/useSubStep/types'; import useThemeStyles from '@hooks/useThemeStyles'; import {getFieldRequiredErrors, isRequiredFulfilled} from '@libs/ValidationUtils'; +import getSubStepValues from '@pages/ReimbursementAccount/utils/getSubStepValues'; import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; -const {AUTHORIZED_TO_BIND_CLIENT_TO_AGREEMENT, PROVIDE_TRUTHFUL_INFORMATION, AGREE_TO_TERMS_AND_CONDITIONS} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; -const STEP_FIELDS = [AUTHORIZED_TO_BIND_CLIENT_TO_AGREEMENT, PROVIDE_TRUTHFUL_INFORMATION, AGREE_TO_TERMS_AND_CONDITIONS]; +const {AUTHORIZED_TO_BIND_CLIENT_TO_AGREEMENT, PROVIDE_TRUTHFUL_INFORMATION, AGREE_TO_TERMS_AND_CONDITIONS, CONSENT_TO_PRIVACY_NOTICE} = INPUT_IDS.ADDITIONAL_DATA.CORPAY; +const STEP_FIELDS = [AUTHORIZED_TO_BIND_CLIENT_TO_AGREEMENT, PROVIDE_TRUTHFUL_INFORMATION, AGREE_TO_TERMS_AND_CONDITIONS, CONSENT_TO_PRIVACY_NOTICE]; function IsAuthorizedToUseBankAccountLabel() { const {translate} = useLocalize(); @@ -36,19 +37,29 @@ function TermsAndConditionsLabel() { ); } +function ConsentToPrivacyNoticeLabel() { + const {translate} = useLocalize(); + return ( + + {translate('agreementsStep.iConsentToThe')} {`${translate('agreementsStep.privacyNotice')}`} + + ); +} + +const INPUT_KEYS = { + PROVIDE_TRUTHFUL_INFORMATION: INPUT_IDS.ADDITIONAL_DATA.CORPAY.PROVIDE_TRUTHFUL_INFORMATION, + AGREE_TO_TERMS_AND_CONDITIONS: INPUT_IDS.ADDITIONAL_DATA.CORPAY.AGREE_TO_TERMS_AND_CONDITIONS, + CONSENT_TO_PRIVACY_NOTICE: INPUT_IDS.ADDITIONAL_DATA.CORPAY.CONSENT_TO_PRIVACY_NOTICE, + AUTHORIZED_TO_BIND_CLIENT_TO_AGREEMENT: INPUT_IDS.ADDITIONAL_DATA.CORPAY.AUTHORIZED_TO_BIND_CLIENT_TO_AGREEMENT, +}; + function Confirmation({onNext}: SubStepProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); - - const defaultValues = { - [AUTHORIZED_TO_BIND_CLIENT_TO_AGREEMENT]: - !!reimbursementAccount?.achData?.corpay?.[AUTHORIZED_TO_BIND_CLIENT_TO_AGREEMENT] ?? reimbursementAccountDraft?.[AUTHORIZED_TO_BIND_CLIENT_TO_AGREEMENT] ?? '', - [PROVIDE_TRUTHFUL_INFORMATION]: !!reimbursementAccount?.achData?.corpay?.[PROVIDE_TRUTHFUL_INFORMATION] ?? reimbursementAccountDraft?.[PROVIDE_TRUTHFUL_INFORMATION] ?? '', - [AGREE_TO_TERMS_AND_CONDITIONS]: !!reimbursementAccount?.achData?.corpay?.[AGREE_TO_TERMS_AND_CONDITIONS] ?? reimbursementAccountDraft?.[AGREE_TO_TERMS_AND_CONDITIONS] ?? '', - }; + const agreementsStepValues = useMemo(() => getSubStepValues(INPUT_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); const validate = useCallback( (values: FormOnyxValues): FormInputErrors => { @@ -66,6 +77,10 @@ function Confirmation({onNext}: SubStepProps) { errors[AGREE_TO_TERMS_AND_CONDITIONS] = translate('common.error.acceptTerms'); } + if (!isRequiredFulfilled(values[CONSENT_TO_PRIVACY_NOTICE])) { + errors[CONSENT_TO_PRIVACY_NOTICE] = translate('agreementsStep.error.consent'); + } + return errors; }, [translate], @@ -88,7 +103,7 @@ function Confirmation({onNext}: SubStepProps) { inputID={AUTHORIZED_TO_BIND_CLIENT_TO_AGREEMENT} style={styles.mt6} LabelComponent={IsAuthorizedToUseBankAccountLabel} - defaultValue={defaultValues[AUTHORIZED_TO_BIND_CLIENT_TO_AGREEMENT]} + defaultValue={agreementsStepValues[AUTHORIZED_TO_BIND_CLIENT_TO_AGREEMENT]} shouldSaveDraft /> + From 5c6c6ec814a7a13b3833ca93df45fb44f58f4028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Muzyk?= Date: Wed, 5 Mar 2025 13:42:10 +0100 Subject: [PATCH 3/8] loader and translation correction --- src/languages/es.ts | 2 +- .../NonUSD/Agreements/subSteps/Confirmation.tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 26b27ef2e076..136ef3237aca 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2549,7 +2549,7 @@ const translations = { error: { authorized: 'Debe ser un funcionario controlador con autorización para operar la cuenta bancaria comercial', certify: 'Por favor certifique que la información es verdadera y exacta', - consent: 'Por favor, consienta el aviso de privacidad', + consent: 'Por favor, acepte el aviso de privacidad', }, }, finishStep: { diff --git a/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx b/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx index efa4a165cda3..f5675654484d 100644 --- a/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx @@ -94,6 +94,7 @@ function Confirmation({onNext}: SubStepProps) { submitButtonText={translate('agreementsStep.accept')} style={[styles.mh5, styles.flexGrow1]} enabledWhenOffline={false} + isLoading={reimbursementAccount?.isFinishingCorpayBankAccountOnboarding} > {translate('agreementsStep.pleaseConfirm')} {translate('agreementsStep.regulationRequiresUs')} From a577f8b6aaa402dfe4e5b8fec3b2b04179e6866b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Muzyk?= Date: Mon, 10 Mar 2025 09:25:24 +0100 Subject: [PATCH 4/8] finish case --- .../NonUSD/NonUSDVerifiedBankAccountFlow.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pages/ReimbursementAccount/NonUSD/NonUSDVerifiedBankAccountFlow.tsx b/src/pages/ReimbursementAccount/NonUSD/NonUSDVerifiedBankAccountFlow.tsx index 1dd74768ce92..300348b4a826 100644 --- a/src/pages/ReimbursementAccount/NonUSD/NonUSDVerifiedBankAccountFlow.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/NonUSDVerifiedBankAccountFlow.tsx @@ -61,6 +61,10 @@ function NonUSDVerifiedBankAccountFlow({nonUSDBankAccountStep, setNonUSDBankAcco case CONST.NON_USD_BANK_ACCOUNT.STEP.AGREEMENTS: setNonUSDBankAccountStep(CONST.NON_USD_BANK_ACCOUNT.STEP.SIGNER_INFO); break; + case CONST.NON_USD_BANK_ACCOUNT.STEP.FINISH: + setShouldShowContinueSetupButton(true); + setNonUSDBankAccountStep(null); + break; default: return null; } From 2ad002c4a622058522ef369272be8e52d83f4278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Muzyk?= Date: Mon, 10 Mar 2025 13:22:29 +0100 Subject: [PATCH 5/8] default step --- src/languages/en.ts | 2 +- .../NonUSD/Agreements/subSteps/Confirmation.tsx | 4 ++-- src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 652b08e8917d..6a7a0e65f5f1 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2518,7 +2518,7 @@ const translations = { regulationRequiresUs: 'Regulation requires us to verify the identity of any individual who owns more than 25% of the business.', iAmAuthorized: 'I am authorized to use the business bank account for business spend.', iCertify: 'I certify that the information provided is true and accurate.', - termsAndConditions: 'terms and conditions.', + termsAndConditions: 'terms and conditions', accept: 'Accept and add bank account', iConsentToThe: 'I consent to the', privacyNotice: 'privacy notice', diff --git a/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx b/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx index f5675654484d..af00b86fb5a7 100644 --- a/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx @@ -118,7 +118,7 @@ function Confirmation({onNext}: SubStepProps) { /> { From c857bb0638242bb6bb18089ab39740d7e6ab1284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Muzyk?= Date: Mon, 24 Mar 2025 11:26:07 +0100 Subject: [PATCH 6/8] fix: unused dependency --- .../ReimbursementAccount/ReimbursementAccountPage.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx index efb7b7fa5ded..334b895b37aa 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx @@ -180,10 +180,9 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen return; } - // TODO double check condition for non USD accounts - will be done in https://github.com/Expensify/App/issues/50912 - setShouldShowConnectedVerifiedBankAccount(hasForeignCurrency ? !!achData?.corpay?.consentToPrivacyNotice : achData?.currentStep === CONST.BANK_ACCOUNT.STEP.ENABLE); + setShouldShowConnectedVerifiedBankAccount(hasForeignCurrency ? achData?.state === CONST.BANK_ACCOUNT.STATE.OPEN : achData?.currentStep === CONST.BANK_ACCOUNT.STEP.ENABLE); setShouldShowContinueSetupButton(shouldShowContinueSetupButtonValue); - }, [achData?.corpay?.consentToPrivacyNotice, achData?.currentStep, shouldShowContinueSetupButtonValue, hasForeignCurrency, isPreviousPolicy]); + }, [achData?.currentStep, shouldShowContinueSetupButtonValue, hasForeignCurrency, isPreviousPolicy, achData?.state]); useEffect( () => { @@ -274,7 +273,7 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen } if (achData?.state === CONST.BANK_ACCOUNT.STATE.VERIFYING) { - setUSDBankAccountStep(CONST.NON_USD_BANK_ACCOUNT.STEP.FINISH); + setNonUSDBankAccountStep(CONST.NON_USD_BANK_ACCOUNT.STEP.FINISH); } }; From 17d01f7c91917c60836678bda55835511cec4ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Muzyk?= Date: Wed, 16 Apr 2025 10:19:35 +0200 Subject: [PATCH 7/8] sort out dot situation --- src/languages/es.ts | 2 +- .../NonUSD/Agreements/subSteps/Confirmation.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index ca35f84a2d5b..59de6b508406 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2733,7 +2733,7 @@ const translations = { regulationRequiresUs: 'La normativa requiere que verifiquemos la identidad de cualquier individuo que posea más del 25% del negocio.', iAmAuthorized: 'Estoy autorizado para usar la cuenta bancaria para gastos del negocio.', iCertify: 'Certifico que la información proporcionada es verdadera y correcta.', - termsAndConditions: 'términos y condiciones.', + termsAndConditions: 'términos y condiciones', accept: 'Agregar y aceptar cuenta bancaria', iConsentToThe: 'Doy mi consentimiento para el', privacyNotice: 'aviso de privacidad', diff --git a/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx b/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx index af00b86fb5a7..25207c138187 100644 --- a/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx @@ -32,7 +32,7 @@ function TermsAndConditionsLabel() { return ( {translate('common.iAcceptThe')} - {`${translate('agreementsStep.termsAndConditions')}`} + {`${translate('agreementsStep.termsAndConditions')}`}. ); } @@ -41,7 +41,7 @@ function ConsentToPrivacyNoticeLabel() { const {translate} = useLocalize(); return ( - {translate('agreementsStep.iConsentToThe')} {`${translate('agreementsStep.privacyNotice')}`} + {translate('agreementsStep.iConsentToThe')} {`${translate('agreementsStep.privacyNotice')}`}. ); } From c5fa095635b81989720358a4bc09bc326a2a9072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Muzyk?= Date: Wed, 16 Apr 2025 11:35:19 +0200 Subject: [PATCH 8/8] lint and clear errors when going back --- .../NonUSD/Agreements/index.tsx | 4 ++-- .../NonUSD/Agreements/subSteps/Confirmation.tsx | 4 ++-- .../NonUSD/NonUSDVerifiedBankAccountFlow.tsx | 3 +++ .../ReimbursementAccountPage.tsx | 16 ++++++++-------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/pages/ReimbursementAccount/NonUSD/Agreements/index.tsx b/src/pages/ReimbursementAccount/NonUSD/Agreements/index.tsx index 3683581b5f23..f8a127285c37 100644 --- a/src/pages/ReimbursementAccount/NonUSD/Agreements/index.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/Agreements/index.tsx @@ -31,8 +31,8 @@ const INPUT_KEYS = { function Agreements({onBackButtonPress, onSubmit}: AgreementsProps) { const {translate} = useLocalize(); - const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); - const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); + const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {canBeMissing: false}); + const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT, {canBeMissing: false}); const agreementsStepValues = useMemo(() => getSubStepValues(INPUT_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); const bankAccountID = reimbursementAccount?.achData?.bankAccountID ?? CONST.DEFAULT_NUMBER_ID; diff --git a/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx b/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx index 25207c138187..978fb00d3819 100644 --- a/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/Agreements/subSteps/Confirmation.tsx @@ -57,8 +57,8 @@ function Confirmation({onNext}: SubStepProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); - const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); + const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {canBeMissing: false}); + const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT, {canBeMissing: false}); const agreementsStepValues = useMemo(() => getSubStepValues(INPUT_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); const validate = useCallback( diff --git a/src/pages/ReimbursementAccount/NonUSD/NonUSDVerifiedBankAccountFlow.tsx b/src/pages/ReimbursementAccount/NonUSD/NonUSDVerifiedBankAccountFlow.tsx index b4db8d70c548..daf40d9f39d0 100644 --- a/src/pages/ReimbursementAccount/NonUSD/NonUSDVerifiedBankAccountFlow.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/NonUSDVerifiedBankAccountFlow.tsx @@ -1,5 +1,7 @@ import React from 'react'; +import {clearErrors} from '@userActions/FormActions'; import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; import Agreements from './Agreements'; import BankInfo from './BankInfo/BankInfo'; import BeneficialOwnerInfo from './BeneficialOwnerInfo/BeneficialOwnerInfo'; @@ -49,6 +51,7 @@ function NonUSDVerifiedBankAccountFlow({ }; const nonUSDBankAccountsGoBack = () => { + clearErrors(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM); switch (nonUSDBankAccountStep) { case CONST.NON_USD_BANK_ACCOUNT.STEP.COUNTRY: setNonUSDBankAccountStep(null); diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx index 6d4dc0fef139..5c620062e4ce 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx @@ -57,13 +57,13 @@ const SUPPORTED_FOREIGN_CURRENCIES: string[] = [CONST.CURRENCY.EUR, CONST.CURREN function ReimbursementAccountPage({route, policy, isLoadingPolicy}: ReimbursementAccountPageProps) { const session = useSession(); - const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); - const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); - const [corpayFields] = useOnyx(ONYXKEYS.CORPAY_FIELDS); - const [plaidCurrentEvent = ''] = useOnyx(ONYXKEYS.PLAID_CURRENT_EVENT); - const [onfidoToken = ''] = useOnyx(ONYXKEYS.ONFIDO_TOKEN); - const [isLoadingApp = false] = useOnyx(ONYXKEYS.IS_LOADING_APP); - const [account] = useOnyx(ONYXKEYS.ACCOUNT); + const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {canBeMissing: true}); + const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT, {canBeMissing: true}); + const [corpayFields] = useOnyx(ONYXKEYS.CORPAY_FIELDS, {canBeMissing: true}); + const [plaidCurrentEvent = ''] = useOnyx(ONYXKEYS.PLAID_CURRENT_EVENT, {canBeMissing: true}); + const [onfidoToken = ''] = useOnyx(ONYXKEYS.ONFIDO_TOKEN, {canBeMissing: true}); + const [isLoadingApp = false] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true}); + const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true}); const [isValidateCodeActionModalVisible, setIsValidateCodeActionModalVisible] = useState(false); const policyName = policy?.name ?? ''; @@ -77,7 +77,7 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen const policyCurrency = policy?.outputCurrency ?? ''; const nonUSDCountryDraftValue = reimbursementAccountDraft?.country ?? ''; const {isDevelopment} = useEnvironment(); - const [isDebugModeEnabled] = useOnyx(ONYXKEYS.USER, {selector: (user) => !!user?.isDebugModeEnabled}); + const [isDebugModeEnabled] = useOnyx(ONYXKEYS.USER, {selector: (user) => !!user?.isDebugModeEnabled, canBeMissing: true}); // TODO once nonUSD flow is complete update the flags below to reflect all supported currencies, this will be updated in - https://github.com/Expensify/App/issues/50912 // TODO remove isDevelopment and isDebugModeEnabled flags once nonUSD flow is complete, this will be updated in - https://github.com/Expensify/App/issues/50912