[$250] Next Steps - Next steps still shows "Waiting for you to add a bank account" after adding BA
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:
- Go to https://staging.new.expensify.com/
- As an admin, create workspace and add an employee
- As an admin, enable workflow and configure the following
- set delay submission to manually
- enable approvals
- add bank account (details below)
- As an employee, submit an expense and click on the submit button.
- As an admin, approve it and click on pay with Expensify once.
- As an admin, Verify the next steps indicate "Waiting for [userSubmitter] to add a bank account"
- As an employee, go to the expense details, click on add bank account and finish the flow(Choose the 0000 bank account)
- 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
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 Owner
Current Issue Owner: @sobitneupane
Triggered auto assignment to @rlinoz (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.
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.
💬 A slack conversation has been started in #expensify-open-source
: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:
- Identify the pull request that introduced this issue and revert it.
- Find someone who can quickly fix the issue.
- Fix the issue yourself.
@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.
I think this might be reproducible in the production branch, let me see
Reproduced in the production branch:
Job added to Upwork: https://www.upwork.com/jobs/~021863967066967992824
Triggered auto assignment to Contributor-plus team member for initial proposal review - @sobitneupane (External)
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) :
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.
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 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."
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.
@rlinoz How should we estimate the date for the payment completion in the frontend? Could you please share the backend logic?
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.
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
After a lot of digging I think this might get fixed entirely with a change in the backend, sorry about that.
PR is in staging
@garrettmknight, @rlinoz, @sobitneupane Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
Deployed to prod