Skip to content
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

[HOLD for payment 2023-11-07] [$500] iOS: "Connect online with Plaid" popup is opened repeatedly after resuming the app. #27616

Closed
1 of 6 tasks
kavimuru opened this issue Sep 17, 2023 · 84 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@kavimuru
Copy link

kavimuru commented Sep 17, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Go to account settings >> Workspace.
  2. Click on the workspace to view its settings.
  3. Click on Cards or Reimbursements settings.
  4. Select "Connect bank account" >> "Connect online with Plaid."
  5. Swipe down from the top of the device's screen to view notifications.
  6. Swipe up to hide notifications.
  7. Observe that the "Connect online with Plaid" popup opens again.

Expected Result:

"Connect online with Plaid" popup is opened only once

Actual Result:

Connect online with Plaid popup is opened repeatedly
NOTE : Can be reproduced with the steps 5. Put app to background and Resume app from background

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.70-5
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

popup-opened-repeatedly-02.MP4
popup-opened-repeatedly-01.MP4
WPNF8768.1.MP4

Expensify/Expensify Issue URL:
Issue reported by: @tranvantoan-qn
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1694619647610939

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01b7bfe22feb2b9545
  • Upwork Job ID: 1703386549654556672
  • Last Price Increase: 2023-09-17
  • Automatic offers:
    • situchan | Contributor | 26773159
    • tranvantoan-qn | Reporter | 26773161
    • pradeepmdk | Contributor | 27260708
@kavimuru kavimuru added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 17, 2023
@melvin-bot melvin-bot bot changed the title iOS: "Connect online with Plaid" popup is opened repeatedly after resuming the app. [$500] iOS: "Connect online with Plaid" popup is opened repeatedly after resuming the app. Sep 17, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 17, 2023

Triggered auto assignment to @CortneyOfstad (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Sep 17, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01b7bfe22feb2b9545

@melvin-bot
Copy link

melvin-bot bot commented Sep 17, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 17, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 17, 2023

Triggered auto assignment to @adelekennedy (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Sep 17, 2023

Triggered auto assignment to Contributor-plus team member for initial proposal review - @ntdiary (External)

@kushu7
Copy link
Contributor

kushu7 commented Sep 17, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

iOS: "Connect online with Plaid" popup is opened repeatedly after resuming the app

What is the root cause of that problem?

Problem is PlaidLink is not getting closed on component unmount.
we are not handling any unmount case here.

onExit: (exitError, metadata) => {
Log.info('[PlaidLink] Exit: ', false, {exitError, metadata});
props.onExit();
},
});
// We generally do not need to include the token as a dependency here as it is only provided once via props and should not change
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

and ReimbursementAccountPage get remounted on focus due to this this.props.isLoadingReportData

const isLoading = this.props.isLoadingReportData || this.props.account.isLoading || this.props.reimbursementAccount.isLoading;

resulting unmounting of PlaidLink due to ReimbursementAccountLoadingIndicator.

What changes do you think we should make in order to solve the problem?

We can update PlaidLink to close Plaid Popover on component unmount.
we can add this code on useEffect cleanup to dismiss PlaidLink on unmount by using dismissLink method of react-native-plaid-link-sdk

const ref = useRef({ isVisible: false })
.....
.....
    useEffect(() => {
        ref.current.isVisible = true
        openLink({
        .....
            onSuccess: ({ publicToken, metadata }) => {
                ref.current.isVisible = false;
                props.onSuccess({ publicToken, metadata });
            },
            onExit: (exitError, metadata) => {
                Log.info('[PlaidLink] Exit: ', false, { exitError, metadata });
                ref.current.isVisible = false;
                props.onExit();
            },
        });

        return () => {
            // eslint-disable-next-line react-hooks/exhaustive-deps
            if (!ref.current.isVisible) return;
            dismissLink();
        }
    }, []);
Result
Simulator.Screen.Recording.-.iPhone.14.Pro.Max.-.2023-09-17.at.19.34.41.mov

What alternative solutions did you explore? (Optional)

None

@pradeepmdk
Copy link
Contributor

pradeepmdk commented Sep 17, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

iOS: "Connect online with Plaid" popup is opened repeatedly after resuming the app

What is the root cause of that problem?

when notification open apps going to background mode. so when the notification closed app again active and reconnect api triggering

const isLoading = this.props.isLoadingReportData || this.props.account.isLoading || this.props.reimbursementAccount.isLoading;

when reconnect api calling isLoadingReportData false and true
component is unmount and mount. so that popup is opening again

What changes do you think we should make in order to solve the problem?

create new onyx key PLAID_CURRENT_EVENT; and store the event in the onyx
function setPlaidEvent(eventName) { return Onyx.set(ONYXKEYS.PLAID_CURRENT_EVENT, eventName); }
save this event from here

// Handle Plaid login errors (will potentially reset plaid token and item depending on the error)

and
subscribe to this event and check the open condition

if ((!this.state.hasACHDataBeenLoaded || isLoading) && shouldShowOfflineLoader && (shouldReopenOnfido || !this.requestorStepRef.current)) {

if ((!this.state.hasACHDataBeenLoaded || (isLoading && this.props.PLAID_CURRENT_EVENT != 'OPEN')) && shouldShowOfflineLoader && (shouldReopenOnfido || !this.requestorStepRef.current)) {
and plaid popup loading mode there is no event so handle that

here we need add props.onEvent('OPEN', {});
and here no unmount handle we can dismiss the link on unmount
// We generally do not need to include the token as a dependency here as it is only provided once via props and should not change

return () => { dismissLink(); }

and finally, we should clear here

function clearPlaid() {
    Onyx.set(ONYXKEYS.PLAID_LINK_TOKEN, '');
    Onyx.set(ONYXKEYS.PLAID_CURRENT_EVENT, '');
    return Onyx.set(ONYXKEYS.PLAID_DATA, PlaidDataProps.plaidDataDefaultProps);
}

Result

Untitled.mp4

@PiyushChandra17
Copy link

PiyushChandra17 commented Sep 18, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

iOS - Connect online with Plaid popup is opened repeatedly

What is the root cause of that problem?

PlaidLink is not getting dismissed when the component unmounts, Hence leads to memory leakage so we need to cleanup this component.

openLink({
tokenConfig: {
token: props.token,
},
onSuccess: ({publicToken, metadata}) => {
props.onSuccess({publicToken, metadata});
},
onExit: (exitError, metadata) => {
Log.info('[PlaidLink] Exit: ', false, {exitError, metadata});
props.onExit();
},
});
// We generally do not need to include the token as a dependency here as it is only provided once via props and should not change
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

and when we swipe down to view notifications, the app gets into background mode and when we swipe up the app activates again resulting in multiple pop overs

const isLoading = this.props.isLoadingReportData || this.props.account.isLoading || this.props.reimbursementAccount.isLoading;

What changes do you think we should make in order to solve the problem?

We need to apply following changes:

  • Update react-native-plaid-link-sdk to the latest version
  • import dismissLink from react-native-plaid-link-sdk
  • update useEffect, add a clean up function and call dismissLink there
useEffect(() => {
        openLink({
            tokenConfig: {
                token: props.token,
            },
            onSuccess: ({publicToken, metadata}) => {
                props.onSuccess({publicToken, metadata});
            },
            onExit: (exitError, metadata) => {
                Log.info('[PlaidLink] Exit: ', false, {exitError, metadata});
                props.onExit();
            },
        });

        return () => {
            dismissLink()
        }

        // We generally do not need to include the token as a dependency here as it is only provided once via props and should not change
        // eslint-disable-next-line react-hooks/exhaustive-deps
        
    }, []);

What alternative solutions did you explore? (Optional)

NA

Result:

Simulator.Screen.Recording.-.iPhone.13.-.2023-09-18.at.06.18.06.mp4

@ginsuma
Copy link
Contributor

ginsuma commented Sep 18, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

PlaidLink popup is opened again after reopening the app from the background.

What is the root cause of that problem?

When the app reopens from the background, ReconnectApp is sent => isLoading is reset => ReimbursementAccountPage returns ReimbursementAccountLoadingIndicator.

const isLoading = this.props.isLoadingReportData || this.props.account.isLoading || this.props.reimbursementAccount.isLoading;

if ((!this.state.hasACHDataBeenLoaded || isLoading) && shouldShowOfflineLoader && (shouldReopenOnfido || !this.requestorStepRef.current)) {
const isSubmittingVerificationsData = _.contains([CONST.BANK_ACCOUNT.STEP.COMPANY, CONST.BANK_ACCOUNT.STEP.REQUESTOR, CONST.BANK_ACCOUNT.STEP.ACH_CONTRACT], currentStep);
return (
<ReimbursementAccountLoadingIndicator
isSubmittingVerificationsData={isSubmittingVerificationsData}
onBackButtonPress={this.goBack}
/>
);
}

This makes BankAccountStep mount again => Plaid popup open one more.

What changes do you think we should make in order to solve the problem?

We use 'achData.subStep' to check if we already select "Connect online with Plaid".
Change the condition below:

if ((!this.state.hasACHDataBeenLoaded || isLoading) && shouldShowOfflineLoader && (shouldReopenOnfido || !this.requestorStepRef.current)) {

To:

const subStep = lodashGet(this.props.reimbursementAccount, 'achData.subStep', '');
if (... && subStep !== CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID)
Result
Screen.Recording.2023-09-18.at.9.21.19.PM.mov

@ntdiary
Copy link
Contributor

ntdiary commented Sep 18, 2023

@kushu7, It seems like the pop-up window will appear and disappear multiple times?
Additionally, a friendly tip, please try to use your own words to fill in the first section of the proposal template (instead of copying the issue title). : )

@ntdiary
Copy link
Contributor

ntdiary commented Sep 19, 2023

Hi, folks, so far, there are two questions that need clarifying:

  1. For the way of changing how loading is rendered, will it cause a regression of issue #18156?
  2. For the way of calling dismissLink on unmount, will the popup still flash multiple times before the final show? (I saw it happening in this result video)

@pradeepmdk
Copy link
Contributor

pradeepmdk commented Sep 19, 2023

@ntdiary can you check my proposal #27616 (comment)

we can check the plaid event so that we can know modal is open or not and lodashGet(props.reimbursementAccount, 'achData.subStep', '') == CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID

@ginsuma
Copy link
Contributor

ginsuma commented Sep 19, 2023

  1. For the way of changing how loading is rendered, will it cause a regression of issue #18156?

@ntdiary I don't think my solution will cause it because subStep data will only saved in local Onyx. When we clear cookies => sign out => Onyx data is reset => the loading indicator will be rendered like before.

@situchan
Copy link
Contributor

I can take this over based on @ntdiary's request

@adelekennedy adelekennedy assigned situchan and unassigned ntdiary Sep 20, 2023
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 20, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 20, 2023

📣 @situchan 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot
Copy link

melvin-bot bot commented Sep 20, 2023

📣 @tranvantoan-qn 🎉 An offer has been automatically sent to your Upwork account for the Reporter role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@melvin-bot melvin-bot bot added the Overdue label Sep 22, 2023
@CortneyOfstad
Copy link
Contributor

@adelekennedy There is a known issue with the external label double-assigning, so going to remove you 👍

@melvin-bot melvin-bot bot removed the Overdue label Sep 22, 2023
@CortneyOfstad
Copy link
Contributor

@tgolen any update on the PR review? Thanks!

@situchan
Copy link
Contributor

@tgolen any update on the PR review? Thanks!

merged and hit staging. GH will be updated upon next deploy

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 31, 2023
@melvin-bot melvin-bot bot changed the title [$500] iOS: "Connect online with Plaid" popup is opened repeatedly after resuming the app. [HOLD for payment 2023-11-07] [$500] iOS: "Connect online with Plaid" popup is opened repeatedly after resuming the app. Oct 31, 2023
Copy link

melvin-bot bot commented Oct 31, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 31, 2023
Copy link

melvin-bot bot commented Oct 31, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.93-1 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-11-07. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter — paid @tranvantoan-qn $50 via Upwork as reporter
  • Contributor that fixed the issue — paid @pradeepmdk $500 via Upwork as Contributor
  • Contributor+ that helped on the issue and/or PR — paid @situchan $500 via Upwork as C+

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Oct 31, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@situchan] The PR that introduced the bug has been identified. Link to the PR:
  • [@situchan] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@situchan] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@situchan] Determine if we should create a regression test for this bug.
  • [@situchan] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@CortneyOfstad] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Nov 7, 2023
@tgolen
Copy link
Contributor

tgolen commented Nov 7, 2023

bump @situchan @CortneyOfstad to complete the above

@melvin-bot melvin-bot bot removed the Overdue label Nov 7, 2023
@CortneyOfstad
Copy link
Contributor

CortneyOfstad commented Nov 7, 2023

Payment Breakdown

  • External issue reporter — paid @tranvantoan-qn $50 via Upwork as reporter
  • Contributor that fixed the issue — paid @pradeepmdk $750 via Upwork as Contributor with Bonus
  • Contributor+ that helped on the issue and/or PR — paid @situchan $750 via Upwork as C+ with Bonus

@situchan
Copy link
Contributor

situchan commented Nov 7, 2023

I think this is eligible for bonus.
Contributor assigned on Oct 18
PR is ready for final review on Oct 20
Merged on Oct 27 but @tgolen was OOO for 1 week

@situchan
Copy link
Contributor

situchan commented Nov 7, 2023

No PR caused this regression. The bug existed always from the beginning.

Regression Test Proposal (iOS, android)

  1. Go to Settings > Workspaces > select workspace > Cards
  2. Click "Connect bank account" > "Connect online with Plaid"
  3. Verify that plaid popup shows
  4. Swipe down from the top of the device's screen to view notifications.
  5. Swipe up to hide notifications.
  6. Verify that current plaid popup keeps open and another plaid popup doesn't show

@CortneyOfstad
Copy link
Contributor

I think this is eligible for bonus.
Contributor #27616 (comment) on Oct 18
PR is ready for final review on Oct 20
Merged on Oct 27 but @tgolen was #29927 (review) for 1 week

@tgolen does that sound correct?

@melvin-bot melvin-bot bot added the Overdue label Nov 9, 2023
@CortneyOfstad
Copy link
Contributor

Bump @tgolen on the question above ^^^ thanks!

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Nov 10, 2023
@tgolen
Copy link
Contributor

tgolen commented Nov 13, 2023

Yeah, that looks correct 👍

@melvin-bot melvin-bot bot removed the Overdue label Nov 13, 2023
@CortneyOfstad
Copy link
Contributor

Thanks for the confirmation @tgolen!

@pradeepmdk @situchan — I sent you both bonus proposals in Upwork — please let me know once you accept and I can get those paid ASAP. Thanks!

@pradeepmdk
Copy link
Contributor

@CortneyOfstad i accepted the offer

@CortneyOfstad
Copy link
Contributor

Payments have been made successfully for the bonus amounts, so working on creating the regression test now 👍

@CortneyOfstad
Copy link
Contributor

Regression test created here — https://github.com/Expensify/Expensify/issues/336141.

Closing as everything has been completed – thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests