-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Fix empty "Upload Additional Documents" page in NonUSD owner flow #91289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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}`); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ PERF-11 (docs)
Use a selector to extract only the needed field: const [outputCurrency] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {
selector: (p) => p?.outputCurrency,
});Then pass the extracted primitive value directly instead of the full policy object. Reviewed at: 16e329e | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency. |
||
|
|
||
| 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}), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ PERF-11 (docs)
useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT)subscribes to the entire reimbursement account object, but onlyachData.countryis used (viagetCurrencyForNonUSDBankAccount). This causes unnecessary re-renders when any unrelated field on the reimbursement account changes.Use a selector to extract only the needed field:
Then pass the extracted value directly instead of the full object, or restructure
getCurrencyForNonUSDBankAccountto accept the primitive values it actually needs.Reviewed at: 16e329e | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.