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

[$250] Next Steps - Next steps still shows "Waiting for you to add a bank account" after adding BA #53468

Closed
3 of 8 tasks
vincdargento opened this issue Dec 3, 2024 · 21 comments
Assignees
Labels
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 Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@vincdargento
Copy link

vincdargento commented Dec 3, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.70-1
Reproducible in staging?: Yes
Reproducible in production?: Unable to validate in Production because of BA setup
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team

Action Performed:

  1. Go to https://staging.new.expensify.com/
  2. As an admin, create workspace and add an employee
  3. As an admin, enable workflow and configure the following
  • set delay submission to manually
  • enable approvals
  • add bank account (details below)
  1. As an employee, submit an expense and click on the submit button.
  2. As an admin, approve it and click on pay with Expensify once.
  3. As an admin, Verify the next steps indicate "Waiting for [userSubmitter] to add a bank account"
  4. As an employee, go to the expense details, click on add bank account and finish the flow(Choose the 0000 bank account)
  5. As an employee, see the next steps after adding bank account.

Expected Result:

After adding bank account the next steps shouldn't show "Waiting for you to add a bank account"

Actual Result:

Next steps says "Waiting for you to add a bank account" even after adding bank account

Workaround:

Unknown

Platforms:

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

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

bug.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021863967066967992824
  • Upwork Job ID: 1863967066967992824
  • Last Price Increase: 2024-12-10
Issue OwnerCurrent Issue Owner: @rlinoz
@vincdargento vincdargento added DeployBlockerCash This issue or pull request should block deployment Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. DeployBlocker Indicates it should block deploying the API labels Dec 3, 2024
Copy link

melvin-bot bot commented Dec 3, 2024

Triggered auto assignment to @rlinoz (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

Copy link

melvin-bot bot commented Dec 3, 2024

Triggered auto assignment to @garrettmknight (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

Copy link

melvin-bot bot commented Dec 3, 2024

💬 A slack conversation has been started in #expensify-open-source

@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Dec 3, 2024
Copy link
Contributor

github-actions bot commented Dec 3, 2024

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@vincdargento
Copy link
Author

@garrettmknight FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors.

@rlinoz
Copy link
Contributor

rlinoz commented Dec 3, 2024

I think this might be reproducible in the production branch, let me see

@rlinoz
Copy link
Contributor

rlinoz commented Dec 3, 2024

Reproduced in the production branch:

Screenshot 2024-12-03 at 12 12 42 Screenshot 2024-12-03 at 12 12 50

@rlinoz rlinoz added Daily KSv2 Hourly KSv2 Help Wanted Apply this label when an issue is open to proposals by contributors External Added to denote the issue can be worked on by a contributor and removed DeployBlockerCash This issue or pull request should block deployment DeployBlocker Indicates it should block deploying the API Hourly KSv2 Daily KSv2 labels Dec 3, 2024
@melvin-bot melvin-bot bot changed the title Next Steps - Next steps still shows "Waiting for you to add a bank account" after adding BA [$250] Next Steps - Next steps still shows "Waiting for you to add a bank account" after adding BA Dec 3, 2024
Copy link

melvin-bot bot commented Dec 3, 2024

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

Copy link

melvin-bot bot commented Dec 3, 2024

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

@M00rish
Copy link
Contributor

M00rish commented Dec 4, 2024

it seems to me like a backend issue, next_step value from onyx does not get updated as soon as bank account is added, after a minute or so it gets updated(or with a reload) :
image

@rlinoz
Copy link
Contributor

rlinoz commented Dec 5, 2024

I mean, backend might be at play here as well, but the fact that we instantly remove the add bank account button makes me think that we can improve this on the App side as well. Maybe even just a better optimistic data.

@melvin-bot melvin-bot bot added the Overdue label Dec 5, 2024
@M00rish
Copy link
Contributor

M00rish commented Dec 5, 2024

Edited by proposal-police: This proposal was edited at 2024-12-05 23:55:30 UTC.

Proposal

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

Next Steps - Next steps still shows "Waiting for you to add a bank account" after adding BA

What is the root cause of that problem?

no optimistic data for this case in addPersonalBankAccount:

optimisticData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_BANK_ACCOUNT,
value: {
isLoading: true,
errors: null,
plaidAccountID: account.plaidAccountID,
},
},
],

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

in this case, we are coming from here:

onPress={() => BankAccounts.openPersonalBankAccountSetupView(Navigation.getTopmostReportId() ?? linkedReport?.reportID, isUserValidated)}

we'll use ExitReportID, after it's merged in onyx:

Onyx.merge(ONYXKEYS.PERSONAL_BANK_ACCOUNT, {exitReportID});

by updating AddPersonalBankAccount to accept it as optional argument

function addPersonalBankAccount(account: PlaidBankAccount,NextStepReportID:string | undefined = undefined) {
.....
    const onyxData: OnyxData = {
        optimisticData: [
            {
                onyxMethod: Onyx.METHOD.MERGE,
                key: ONYXKEYS.PERSONAL_BANK_ACCOUNT,
                value: {
                    isLoading: true,
                    errors: null,
                    plaidAccountID: account.plaidAccountID,
                },
            },
            {
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${NextStepReportID ?? ''}`,
                value: NextStepReportID ? buildOptmisticNextStepAfterBA() : '',
            },
        ],

buildOptmisticNextStepAfterBA will build the optmisticNextStep:

function buildOptmisticNextStepAfterBA(){
    const type: ReportNextStep['type'] = 'neutral';
    const optimisticNextStep: ReportNextStep = {
        type,
        icon: CONST.NEXT_STEP.ICONS.STOPWATCH,
        message: [
            {
                text: 'Waiting for ',
            },
            {
                text: `payment`,
            },
            {
                text: ' to ',
            },
            {
                text: 'complete',
            },
            {
                text: `By ${DateUtils.getFiveDaysFromNow().split(' ')[0]}`,
            },
        ],
    };

    return optimisticNextStep;
}

and we'll update addPersonalBankAccount use here :

 BankAccounts.addPersonalBankAccount(selectedPlaidBankAccount,personalBankAccount?.exitReportID);

changes are in this branch

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

cases to test:

  • employee without BA
  • employee already with BA

What alternative solutions did you explore? (Optional)

for optimisticNextStep we can use instead buildNextStep:

function addPersonalBankAccount(account: PlaidBankAccount,NextStepReportID:string | undefined = undefined) {
const [report] =  useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${NextStepReportID}`) ?? '';
const optimisticNextStep = report ? buildNextStep(report,CONST.REPORT.STATUS_NUM.REIMBURSED) : '';
.....
    const onyxData: OnyxData = {
        optimisticData: [
            {
                onyxMethod: Onyx.METHOD.MERGE,
                key: ONYXKEYS.PERSONAL_BANK_ACCOUNT,
                value: {
                    isLoading: true,
                    errors: null,
                    plaidAccountID: account.plaidAccountID,
                },
            },
            {
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${NextStepReportID ?? ''}`,
                value: optimisticNextStep,
            },
        ],

and in buildNextStep we to update the REIMBURSED case:

case CONST.REPORT.STATUS_NUM.REIMBURSED:
  optimisticNextStep= {
          type,
          icon: CONST.NEXT_STEP.ICONS.STOPWATCH,
          message: [
              {
                  text: 'Waiting for ',
              },
              {
                  text: `payment`,
              },
              {
                  text: ' to ',
              },
              {
                  text: 'complete',
              },
              {
                  text: `By ${DateUtils.getFiveDaysFromNow().split(' ')[0]}`,
              },
          ],
      };
    break;

i still have a question in terms of the backend, if a report is paid, will it always send same response waiting for payment to complete...,? or there are cases where no action is required.

@sobitneupane
Copy link
Contributor

@M00rish Thanks for the proposal:

            text: `By ${DateUtils.getFiveDaysFromNow().split(' ')[0]}`,

I don't think we can be completely sure that the payment will be completed within five days. Could you share why you chose this value? I believe we should align with the logic used in the backend, if possible.

There’s a buildNextStep function in NextStepUtils that, I believe, should handle this specific case as well."

@melvin-bot melvin-bot bot removed the Overdue label Dec 9, 2024
@M00rish
Copy link
Contributor

M00rish commented Dec 9, 2024

yes we can't be sure about that period, during my testing it added 5 five days, but it's something that we have to confirm with backend on how they calculate that value(is it based on days or hours etc...) so we simulate on the front end.

i updated my proposal with alternative solution to use NextStepUtils.buildNextStep, @sobitneupane, thanks.

@sobitneupane
Copy link
Contributor

@rlinoz How should we estimate the date for the payment completion in the frontend? Could you please share the backend logic?

@rlinoz
Copy link
Contributor

rlinoz commented Dec 9, 2024

Ah crap, we actually have a expectedReimbursementDate that I though we sent to the FE, but apparently we don't, let me check what we can do.

Copy link

melvin-bot bot commented Dec 10, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@rlinoz
Copy link
Contributor

rlinoz commented Dec 12, 2024

After a lot of digging I think this might get fixed entirely with a change in the backend, sorry about that.

@melvin-bot melvin-bot bot added the Overdue label Dec 12, 2024
@rlinoz
Copy link
Contributor

rlinoz commented Dec 12, 2024

PR is in staging

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Dec 12, 2024
Copy link

melvin-bot bot commented Dec 16, 2024

@garrettmknight, @rlinoz, @sobitneupane Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@rlinoz
Copy link
Contributor

rlinoz commented Dec 16, 2024

Deployed to prod

@rlinoz rlinoz closed this as completed Dec 16, 2024
@melvin-bot melvin-bot bot removed the Overdue label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

5 participants