Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
2.99k stars 2.5k forks source link

[$250] Wrong "Next step" displayed for the approver #41614

Open m-natarajan opened 2 weeks ago

m-natarajan commented 2 weeks ago

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


Version Number: 1.4.70-1 Reproducible in staging?: Yes Reproducible in production?: Yes 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 Expensify/Expensify Issue URL: Issue reported by: @JmillsExpensify Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1714518611299619

Action Performed:

Prerequisite: Have a collect workspace with admin, approver, and employee.

  1. Employee submits report to approver
  2. Approver approves the report
  3. Observe the next step header for approver

    Expected Result:

    "Waiting for you to pay these expenses" should not be displayed for the approver

    Actual Result:

    "Waiting for you to pay these expenses" is displayed for approver who is not configured to pay the report

    Workaround:

    Unknown

    Platforms:

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

    • [ ] Android: Native
    • [ ] Android: mWeb Chrome
    • [ ] iOS: Native
    • [ ] iOS: mWeb Safari
    • [X] MacOS: Chrome / Safari
    • [ ] MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

CleanShot 2024-04-30 at 17 09 15@2x

https://github.com/Expensify/App/assets/38435837/f10ac540-36d7-4afa-990d-7ae177a84e52

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01e9b6cf8e506af2ea
  • Upwork Job ID: 1787692015561465856
  • Last Price Increase: 2024-05-07
  • Automatic offers:
    • dukenv0307 | Reviewer | 0
Issue OwnerCurrent Issue Owner: @dukenv0307
melvin-bot[bot] commented 2 weeks ago

Triggered auto assignment to @adelekennedy (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.

cretadn22 commented 2 weeks ago

Proposal

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

Payer is wrong in the header

What is the root cause of that problem?

When an employee creates a money request, the backend returns a request report where the managerID is the ID of the approver

https://github.com/Expensify/App/blob/2f5173c9c0f041967acfbdf9581ce52327623fa6/src/libs/NextStepUtils.ts#L302-L309

Given that managerDisplayName is "you"

If I understand correctly:

If this understanding is accurate, then the current logic here is wrong

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

We need to extract the approverID from the policy using approverID = policy.submitsTo. Then

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

melvin-bot[bot] commented 1 week ago

@adelekennedy Whoops! This issue is 2 days overdue. Let's get this updated quick!

melvin-bot[bot] commented 1 week ago

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

melvin-bot[bot] commented 1 week ago

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

adelekennedy commented 1 week ago

@dukenv0307 just one proposal to review so far

dominictb commented 1 week ago

Proposal

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

"Waiting for you to pay these expenses" is displayed for approver who is not configured to pay the report

What is the root cause of that problem?

The logic we have here is wrong, in this case there's no further action required from the approver so the message shown is incorrect

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

Since there's no further action required from the approver in this case, we can update this to the No further action required! next step like in here, this is also consistent with what the back-end returns.

Or we can use the no action required message for the whole block here (except the case where the current user is the payer of the request too)

What alternative solutions did you explore? (Optional)

Early return No further action required! next step in here if the current user cannot pay the request (eg. Is not one of the workspace admins, the full condition for checking if user can pay the request is here and !ReportUtils.isInvoiceReport here)

dukenv0307 commented 1 week ago

starting review now

dukenv0307 commented 1 week ago

I like @dominictb's alternative solution

πŸŽ€πŸ‘€πŸŽ€ C+ reviewed

melvin-bot[bot] commented 1 week ago

Triggered auto assignment to @flodnv, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

trjExpensify commented 1 week ago

@mountiny fancy giving this proposal a review?

melvin-bot[bot] commented 1 week ago

πŸ“£ @dukenv0307 πŸŽ‰ An offer has been automatically sent to your Upwork account for the Reviewer role πŸŽ‰ Thanks for contributing to the Expensify app!

Offer link Upwork job

melvin-bot[bot] commented 1 week ago

πŸ“£ @dominictb You have been assigned to this job! Please apply to the Upwork job and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review πŸ§‘β€πŸ’» Once you apply to this job, your Upwork ID will be stored and you will be automatically hired for future jobs! Keep in mind: Code of Conduct | Contributing πŸ“–

mountiny commented 1 week ago

Happy to take this over from Flo as I have worked on the next steps before.

@dominictb Your alternative solution looks better. When the isOwner condition was implemented, we still did not have the policy reimburser data in the App or policy settings. Now, we should use the method you have mentioned in the alternative solutions or the isPayer logic, needs to be checked thoroughly. This should ensure the payer will get this message correctly.