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
3.53k stars 2.88k forks source link

[HOLD for payment 2024-10-24] [$250] Report -Approval button is loaded indefinitely after payment of the report with hold expense #48999

Closed IuliiaHerets closed 1 week ago

IuliiaHerets commented 1 month 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: 9.0.32-0 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4947393 Email or phone of affected tester (no customers): sustinov@applausemail.com Issue reported by: Applause Internal Team

Action Performed:

Prerequisites: Create 3 accounts Admin, Approver, Employee. Create WS as Admin, add two members Approver, Employee. In Workflow, add the Approver member as an expense approver. On behalf of Employee, send two expenses to the WS room.

Steps:

  1. Open NewExpensify app
  2. Log in with your Approver account
  3. Go to the room with the two expenses sent by the employee
  4. Withhold one expense
  5. Go back to the room with the employee
  6. Approve just the pending amount

Expected Result:

The approval button should load immediately after payment of the report with hold expense

Actual Result:

Approval button is loaded indefinitely after payment of the report with hold expense

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

https://github.com/user-attachments/assets/d9efe5dd-4aa1-424b-86cd-df46d245d891

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021836106125438284178
  • Upwork Job ID: 1836106125438284178
  • Last Price Increase: 2024-09-24
  • Automatic offers:
    • akinwale | Reviewer | 104159450
    • nkdengineer | Contributor | 104159452
Issue OwnerCurrent Issue Owner: @muttmuure
melvin-bot[bot] commented 1 month ago

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

IuliiaHerets commented 1 month ago

We think that this bug might be related to #wave-collect - Release 1

IuliiaHerets commented 1 month ago

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

nkdengineer commented 1 month ago

Edited by proposal-police: This proposal was edited at 2024-09-12 07:47:49 UTC.

Proposal

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

Approval button is loaded indefinitely after payment of the report with hold expense

What is the root cause of that problem?

We display the loading state based on canAllowSettlement check

https://github.com/Expensify/App/blob/336e4782aec98bb29a06c28e0d630c276d4eddf6/src/components/ReportActionItem/ReportPreview.tsx#L500 https://github.com/Expensify/App/blob/336e4782aec98bb29a06c28e0d630c276d4eddf6/src/components/ReportActionItem/ReportPreview.tsx#L159

In this function, we have this check hasOptimisticHeldExpense. When we approve only unhold expenses, all transactions of the new expense report are held but we don't update unheldTotal in optimistic data then this check is always true which causes the approve button loading infinitely until we open the expense report or reload to get the unheldTotal of expense report from BE.

https://github.com/Expensify/App/blob/336e4782aec98bb29a06c28e0d630c276d4eddf6/src/libs/ReportUtils.ts#L7184

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

We can update exactly unheldTotal of new expense report to 0 in optimistic data when we build the onyx data here since all transactions are held

onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${optimisticExpenseReport.reportID}`,
value: {
    ...optimisticExpenseReport,
    unheldTotal: 0,
},

https://github.com/Expensify/App/blob/336e4782aec98bb29a06c28e0d630c276d4eddf6/src/libs/actions/IOU.ts#L6460-L6461

OPTIONAL: We can accept unheldTotal param in buildOptimisticExpenseReport function. If it is undefined, we will update this field as total param otherwise use unheldTotal param. Then pass this param as 0 when we build the optimistic data here.

What alternative solutions did you explore? (Optional)

NA

melvin-bot[bot] commented 1 month ago

@muttmuure Eep! 4 days overdue now. Issues have feelings too...

melvin-bot[bot] commented 1 month ago

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

melvin-bot[bot] commented 1 month ago

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

melvin-bot[bot] commented 1 month ago

πŸ“£ It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? πŸ’Έ

nkdengineer commented 1 month ago

@akinwale Can you please review my proposal above, thanks

melvin-bot[bot] commented 1 month ago

@akinwale, @muttmuure Still overdue 6 days?! Let's take care of this!

akinwale commented 1 month ago

We can move forward with @nkdengineer's proposal here.

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

melvin-bot[bot] commented 1 month ago

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

melvin-bot[bot] commented 1 month ago

πŸ“£ @akinwale πŸŽ‰ 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 month ago

πŸ“£ @nkdengineer πŸŽ‰ 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[bot] commented 3 weeks ago

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

melvin-bot[bot] commented 3 weeks ago

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

If no regressions arise, payment will be issued on 2024-10-24. :confetti_ball:

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

melvin-bot[bot] commented 3 weeks ago

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:

akinwale commented 2 weeks ago

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:

  • [x] [@akinwale] The PR that introduced the bug has been identified. Link to the PR:
  • [x] [@akinwale] 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:
  • [x] [@akinwale] 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:

Not a regression.

  • [x] [@akinwale] Determine if we should create a regression test for this bug.
  • [x] [@akinwale] 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.

Regression Test Steps

  1. Launch 2 instances of Expensify
  2. Log in as an approver of a workspace on one instance, and as an employee of the same workspace on the other instance
  3. As employee: Navigate to the report with two duplicate expenses
  4. As employee: Hold one of the expenses
  5. As approver: Approve the pending amount on the non-held expense
  6. As approver: Navigate back to the room by clicking on the header
  7. Verify that the approval button is displayed after payment of the report containing the held expense.

Do we agree πŸ‘ or πŸ‘Ž?

tgolen commented 2 weeks ago

Not a regression.

If this isn't a regression, was it just something missed or a bug in the original feature?

tgolen commented 1 week ago

bump on my question @akinwale

melvin-bot[bot] commented 1 week ago

@tgolen, @akinwale, @muttmuure, @nkdengineer Huh... This is 4 days overdue. Who can take care of this?

akinwale commented 1 week ago

Not a regression.

If this isn't a regression, was it just something missed or a bug in the original feature?

It's more likely something that was missed with the checks for unheldTotal. I wasn't able to find a recent change that introduced the issue.

tgolen commented 1 week ago

OK, thank you! I'll let @muttmuure finish this one up then. I think it's ready to be closed.

muttmuure commented 1 week ago

All paid up