fix: restart the flow for another policy#49687
Conversation
|
@DylanDylann Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
mountiny
left a comment
There was a problem hiding this comment.
@DylanDylann what is your ETA for testing on this pr?
|
If we rush, I can start now |
|
We do not rush specifically, just asking 😂 |
|
|
||
| function ReimbursementAccountPage({route, policy}: ReimbursementAccountPageProps) { | ||
| const session = useSession(); | ||
| const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP); |
There was a problem hiding this comment.
Should we add a fallback value as before?
Same to plaidLinkToken, onfidoToken, plaidCurrentEvent
There was a problem hiding this comment.
I don't think we need it
There was a problem hiding this comment.
@koko57 Why don't you think we need it? Let's see the our previous implementation
There was a problem hiding this comment.
@DylanDylann I don't see anywhere in the app we're using fallback values for the values from useOnyx. And here if we get undefined or null to won't break anything, the conditions will work the same and the TS is not complaining. So I don't see the reason to add these fallbacks.
There was a problem hiding this comment.
but ok, I see that it was implemented in the conflicting file
Co-authored-by: Vit Horacek <36083550+mountiny@users.noreply.github.com> Co-authored-by: DylanDylann <141406735+DylanDylann@users.noreply.github.com>
|
@mountiny @DylanDylann comments addressed. @DylanDylann I had to reverse your suggestion with parentheses, because prettier was failing. It works as it's supposed |
|
@DylanDylann could you please test other ways that we can get to VBBA that you may know? |
That would be namely:
|
|
@mountiny yes, thanks! the first one I also tested myself - it's in the video, but I haven't tested the bottom-up flow |
|
@koko57 Also please resolve conflict |
|
@DylanDylann conflicts resolved, could you please retest it? |
| */ | ||
| function hasInProgressVBBA(): boolean { | ||
| return !!achData?.bankAccountID && achData?.state !== BankAccount.STATE.OPEN && achData?.state !== BankAccount.STATE.LOCKED; | ||
| return !!achData?.state && achData?.state !== BankAccount.STATE.OPEN && achData?.state !== BankAccount.STATE.LOCKED; |
There was a problem hiding this comment.
Why do you remove bankAccountID check here? We need to check bankAccountID condition before display continue setup button (in getShouldShowContinueSetupButtonInitialValue function)
Screen.Recording.2024-10-01.at.14.25.21.mov
There was a problem hiding this comment.
@DylanDylann I don't remember, but ok reverting it.
| } | ||
|
|
||
| useEffect(() => { | ||
| if (!isReimbursementAccountLoading) { |
There was a problem hiding this comment.
we no longer use isReimbursementAccountLoading here. I removed the local state we're just taking the info about the loading from Onyx. We don't need it locally
There was a problem hiding this comment.
@koko57 I mean should we replace with reimbursementAccount?.isLoading
There was a problem hiding this comment.
temporarily different timezone 😃
There was a problem hiding this comment.
but here I'm changing the logic a bit. This runs only when component mounts. As we no longer set the state like this:
const [isReimbursementAccountLoading, setIsReimbursementAccountLoading] = useState(() => {
// By default return true (loading), if there are already loaded data we can skip the loading state
if (hasACHDataBeenLoaded && typeof reimbursementAccount?.isLoading === 'boolean' && !reimbursementAccount?.isLoading) {
return false;
}
return true;
});
we don't need to check if it's true or false and skip the content of the hook. We also don't need to check for reimbursementAccount?.isLoading, we set it true later and we actually want the whole hook to run on mount. We only don't want to fetch the data if it's the same policy as we already have the data.
|
@mountiny The change seems more complicated than I thought. I need more time to complete the checklist. (maybe done in tomorrow) |
|
Thanks! |
| BankAccounts.setBankAccountSubStep(CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL).then(() => { | ||
| setShouldShowContinueSetupButton(false); | ||
| }); | ||
| fetchData(true); |
There was a problem hiding this comment.
@koko57 same here, Why do you remove this line?
There was a problem hiding this comment.
we don't need to fetch the data here. Besides, when I was working on that that call to API seemed not to be sent
There was a problem hiding this comment.
@koko57 To safe, If we remove this, I think we need to understand why we added it before
There was a problem hiding this comment.
This flow is quite complicated. So we should be careful about this change to avoid regression. Thanks
There was a problem hiding this comment.
@DylanDylann as we fetchData when the component mounts we don't need to fetch it once again when we choose manual flow. And as I said - when working on it I've never saw this request being sent (not sure why).
There was a problem hiding this comment.
@DylanDylann yeah it's complicates 😅 I've tried to simplify it as much as possible.
| }, | ||
| // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps | ||
| [isOffline, reimbursementAccount, route, hasACHDataBeenLoaded, shouldShowContinueSetupButton], | ||
| [isOffline, reimbursementAccount, route, hasACHDataBeenLoaded, shouldShowContinueSetupButton, policyIDParam], |
There was a problem hiding this comment.
I think this is unnecessary. When policyIDParam change this component will be rendered for sure (because policyIDParam change means that the route change). Please correct me if I am wrong
There was a problem hiding this comment.
yep and we no longer use it here - removed!
| return; | ||
| } | ||
| setIsReimbursementAccountLoading(reimbursementAccount.isLoading); | ||
| setHasACHDataBeenLoaded(true); |
There was a problem hiding this comment.
@koko57 In case of isLoading is updated from false to true, It will be incorrect. Wdyt If we remove this useEffect? As I understand, this useEffect is to update the deprecated state that no longer use
There was a problem hiding this comment.
@DylanDylann yep, I think that makes sense. Although I must have had some idea why I changed this, but I don't remember now 😅
I will check and remove this useEffect or refactor it
Thanks for pointing this out!
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-10-03.at.22.58.57.movAndroid: mWeb ChromeScreen.Recording.2024-10-03.at.22.57.25.moviOS: NativeScreen.Recording.2024-10-03.at.22.55.46.moviOS: mWeb SafariScreen.Recording.2024-10-03.at.22.55.12.movMacOS: Chrome / SafariScreen.Recording.2024-10-03.at.22.52.42.movMacOS: DesktopScreen.Recording.2024-10-03.at.22.54.17.mov |
|
@DylanDylann seems like removing this useEffect doesn't break anything, could you please retest it? |
| function getFieldsForStep(step: TBankAccountStep): InputID[] { | ||
| switch (step) { | ||
| case CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT: | ||
| return ['routingNumber', 'accountNumber', 'bankName', 'plaidAccountID', 'plaidAccessToken', 'isSavings']; |
There was a problem hiding this comment.
Is there a reason these aren't also CONST?
There was a problem hiding this comment.
not sure, it was implemented like that before, I've just taken this function out of the component
There was a problem hiding this comment.
I think this is not a blocker for now, we can add consts in future PRs if we think it would be cleaner
|
@grgia Is there any blocker here? |
| function getFieldsForStep(step: TBankAccountStep): InputID[] { | ||
| switch (step) { | ||
| case CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT: | ||
| return ['routingNumber', 'accountNumber', 'bankName', 'plaidAccountID', 'plaidAccessToken', 'isSavings']; |
There was a problem hiding this comment.
I think this is not a blocker for now, we can add consts in future PRs if we think it would be cleaner
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.0.46-0 🚀
|
|
🚀 Deployed to production by https://github.com/thienlnam in version: 9.0.46-5 🚀
|
Details
Fixed Issues
$ #49447
PROPOSAL:
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel so the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2024-09-26.at.19.18.23.mp4
MacOS: Desktop