Repository navigation
[Payment due @ZhenjaHorbach] [Wise][Release 1] UI - Update Dismiss Banner Entry Trigger #106737
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
Changes from all commits
29bd7e0
da776f7
01d99a7
67b57cd
af95b46
4ddfe7f
e37b4e5
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 |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import type {Primitive} from 'type-fest'; | ||
|
|
||
| import {useState} from 'react'; | ||
|
|
||
| import useIsScreenFocused from './useIsScreenFocused'; | ||
| import useResponsiveLayout from './useResponsiveLayout'; | ||
|
|
||
| /** | ||
| * Keeps a screen showing what the user last saw while the RHP covers part of it. | ||
| * Returns the live value while the screen has focus, and the value from when it last had focus otherwise, | ||
| * so changes made from the RHP show once it closes instead of shifting the layout visible beside it. | ||
| * Only primitives are accepted, since a value rebuilt on every render would never match the stored one and would set state on every render. | ||
| */ | ||
| function useDeferUntilScreenRevealed<TValue extends Primitive>(value: TValue): TValue { | ||
| const isFocused = useIsScreenFocused(); | ||
| const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
| const [deferredValue, setDeferredValue] = useState(value); | ||
|
|
||
| // On narrow layout the RHP covers the whole screen, so changes can apply while it is hidden. | ||
| // Holding them would make the screen jump as the user navigates back to it. | ||
| const shouldUseLiveValue = isFocused || shouldUseNarrowLayout; | ||
|
|
||
| if (shouldUseLiveValue && !Object.is(deferredValue, value)) { | ||
| setDeferredValue(value); | ||
| } | ||
|
|
||
| return shouldUseLiveValue ? value : deferredValue; | ||
| } | ||
|
|
||
| export default useDeferUntilScreenRevealed; | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -290,10 +290,24 @@ function isWiseOnboardingSubmitted(accountData: AccountData | undefined): boolea | |
| return !!accountData?.additionalData?.wise?.status; | ||
| } | ||
|
|
||
| /** | ||
| * Whether the admin saved part of the Wise onboarding for any of their bank accounts. The server sets Wise as the provider on the first saved page, | ||
| * and from then on Wallet shows the account's setup so the admin can return to it. | ||
| * An account deleted offline still counts until the server removes it, so the banners don't show up before the deletion goes through. | ||
| */ | ||
| function hasStartedWiseOnboarding(bankAccountList: OnyxEntry<OnyxTypes.BankAccountList>): boolean { | ||
| return Object.values(bankAccountList ?? {}).some((bankAccount) => bankAccount?.accountData?.additionalData?.globalReimbursementProvider === CONST.GLOBAL_REIMBURSEMENT_PROVIDER.WISE); | ||
| } | ||
|
|
||
| /** | ||
| * Picks the bank account the Wallet global reimbursements banner points to: the most recently added eligible account. | ||
| */ | ||
| function getWiseGlobalReimbursementsBannerBankAccountID(bankAccountList: OnyxEntry<OnyxTypes.BankAccountList>): number | undefined { | ||
| // Once any account has a Wise setup, Wallet shows where it stands, so the banner has nothing left to promote | ||
| if (hasStartedWiseOnboarding(bankAccountList)) { | ||
| return undefined; | ||
|
Comment on lines
+307
to
+308
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.
For users who pressed Get started before this version and backed out before saving, the old handler has already persisted both banner entries with Useful? React with 👍 / 👎.
Contributor
Author
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. Not addressing this one: the feature is behind the WISE_REIMBURSEMENTS beta, so we don’t need to migrate dismissals saved by the old trigger. QA can use a fresh account or clear nvp_dismissedProductTraining. |
||
| } | ||
|
|
||
| const newest = Object.values(bankAccountList ?? {}).reduce<AccountData | undefined>((latest, bankAccount) => { | ||
| // Accounts deleted offline stay in the list until the request syncs | ||
| if (bankAccount.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) { | ||
|
|
@@ -334,6 +348,11 @@ function getWorkspaceWiseGlobalReimbursementsBannerBankAccountID(policy: OnyxEnt | |
| return undefined; | ||
| } | ||
|
|
||
| // Once any account has a Wise setup, Wallet shows where it stands, so the banner has nothing left to promote | ||
| if (hasStartedWiseOnboarding(bankAccountList)) { | ||
| return undefined; | ||
| } | ||
|
|
||
| // Admins without a copy of the account can't see its currency, type or verifications, so the banner stays hidden for them | ||
| const bankAccount = bankAccountList?.[bankAccountID]; | ||
| if (bankAccount?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || !isBankAccountEligibleForGlobalReimbursements(bankAccount?.accountData, bankAccount?.bankCurrency)) { | ||
|
|
||
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.
@WojtekBoman is this a new pattern or could this hook be used elsewhere? curious that we dont have similar behavior in app already
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.
It’s a new pattern. Usually we want the screen next to the RHP to update live, so this hasn’t come up much. Here, saving the onboarding removes the banner, which makes the page jump while the RHP is still open. The hook keeps the old value until the RHP closes. It’s generic, so it could be reused if the same case comes up somewhere else :)