App icon indicating copy to clipboard operation
App copied to clipboard

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

Open vincdargento opened this issue 1 year ago • 16 comments

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
  • [x] Android: mWeb Chrome
  • [ ] iOS: Standalone
  • [ ] iOS: HybridApp
  • [x] iOS: mWeb Safari
  • [x] MacOS: Chrome / Safari
  • [ ] MacOS: Desktop

Screenshots/Videos

https://github.com/user-attachments/assets/2d597983-d2b9-4ac5-90d5-9f7725505607

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-03
Issue OwnerCurrent Issue Owner: @sobitneupane

vincdargento avatar Dec 03 '24 14:12 vincdargento

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

melvin-bot[bot] avatar Dec 03 '24 14:12 melvin-bot[bot]

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.

melvin-bot[bot] avatar Dec 03 '24 14:12 melvin-bot[bot]

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

melvin-bot[bot] avatar Dec 03 '24 14:12 melvin-bot[bot]

:wave: 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.

github-actions[bot] avatar Dec 03 '24 14:12 github-actions[bot]

@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.

vincdargento avatar Dec 03 '24 14:12 vincdargento

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

rlinoz avatar Dec 03 '24 14:12 rlinoz

Reproduced in the production branch:

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

rlinoz avatar Dec 03 '24 15:12 rlinoz

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

melvin-bot[bot] avatar Dec 03 '24 15:12 melvin-bot[bot]

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

melvin-bot[bot] avatar Dec 03 '24 15:12 melvin-bot[bot]

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

M00rish avatar Dec 04 '24 19:12 M00rish

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.

rlinoz avatar Dec 05 '24 13:12 rlinoz

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: https://github.com/Expensify/App/blob/da7252dd80aa185068ddf5e2a5522bc01fec8b1c/src/libs/actions/BankAccounts.ts#L212-L222

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

in this case, we are coming from here: https://github.com/Expensify/App/blob/840c227be7fd907ab096cda7d6f28e1eef4a1d30/src/pages/home/report/ReportActionItem.tsx#L620

we'll use ExitReportID, after it's merged in onyx: https://github.com/Expensify/App/blob/840c227be7fd907ab096cda7d6f28e1eef4a1d30/src/libs/actions/BankAccounts.ts#L79

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.

M00rish avatar Dec 05 '24 23:12 M00rish

@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."

sobitneupane avatar Dec 09 '24 08:12 sobitneupane

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.

M00rish avatar Dec 09 '24 10:12 M00rish

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

sobitneupane avatar Dec 09 '24 11:12 sobitneupane

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.

rlinoz avatar Dec 09 '24 13:12 rlinoz

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

melvin-bot[bot] avatar Dec 10 '24 16:12 melvin-bot[bot]

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

rlinoz avatar Dec 12 '24 14:12 rlinoz

PR is in staging

rlinoz avatar Dec 12 '24 17:12 rlinoz

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

melvin-bot[bot] avatar Dec 16 '24 09:12 melvin-bot[bot]

Deployed to prod

rlinoz avatar Dec 16 '24 13:12 rlinoz