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

[HOLD for payment 2024-07-10] [$250] Partial approved reports don’t have GBR in the LHN #43014

Closed
1 of 6 tasks
m-natarajan opened this issue Jun 3, 2024 · 52 comments
Closed
1 of 6 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@m-natarajan
Copy link

m-natarajan commented Jun 3, 2024

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.78-3
Reproducible in staging?: y
Reproducible in production?: y
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/p1717128748434439

Action Performed:

  1. Pre-requisite: Create a Collect workspace with user A (member) and user B (admin).
  2. Pre-requisite: Enable approvals and have user B approve for user A
  3. Have user A create several expenses
  4. As user B, hold one of the expenses
  5. Click approve and choose to partial approve what isn’t held

Expected Result:

The newly created report for the held expense is GBR’ed in the LHN

Actual Result:

The newly created report is not GBRed in the LHN

Workaround:

unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

CleanShot 2024-05-30 at 22 12 43

Recording.170.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01a11884101dc8ca36
  • Upwork Job ID: 1798821044516715695
  • Last Price Increase: 2024-06-13
  • Automatic offers:
    • allgandalf | Reviewer | 102784355
    • dominictb | Contributor | 102784358
Issue OwnerCurrent Issue Owner: @johncschuster
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 3, 2024
Copy link

melvin-bot bot commented Jun 3, 2024

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

@dragnoir
Copy link
Contributor

dragnoir commented Jun 4, 2024

I was able to reproduce it. But after a while, the GBR is displayed in the LNH without any updates from me!!

@melvin-bot melvin-bot bot added the Overdue label Jun 6, 2024
@johncschuster johncschuster added the External Added to denote the issue can be worked on by a contributor label Jun 6, 2024
Copy link

melvin-bot bot commented Jun 6, 2024

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

@melvin-bot melvin-bot bot changed the title Partial approved reports don’t have GBR in the LHN [$250] Partial approved reports don’t have GBR in the LHN Jun 6, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 6, 2024
Copy link

melvin-bot bot commented Jun 6, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label Jun 6, 2024
@dominictb
Copy link
Contributor

dominictb commented Jun 7, 2024

Proposal

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

The newly created report is not GBRed in the LHN

What is the root cause of that problem?

When checking if the chat report should show GBR in optimistic data of approveMoneyRequest, the app has this condition.

If the action.childReportID of the report preview report action is the same as excludedIOUReportID, it will be skipped when evaluating GBR. This works well before because when the IOU is approved in full, there won't be any pending action left for that IOU (excludedIOUReportID) so it makes sense to skip it when checking hasOutstandingChildRequest to show GBR.

However, after "partial approval/payment" is introduced, this is no longer working well because when the user "partially approve/pay" an IOU, that IOU is still requiring action (for the partial part that's not approved/paid).

So in this case a hasOutstandingChildRequest is updated to false in optimistic data and only becomes true after the request returns from the back-end.

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

Update this

hasOutstandingChildRequest: hasIOUToApproveOrPay(chatReport, expenseReport?.reportID ?? ''),
such that if the approval is "partial", it will not pass in any excludedIOUReportID. excludedIOUReportID should only be there, we should only exclude it if the approval is full.

hasOutstandingChildRequest: hasIOUToApproveOrPay(chatReport, full ? expenseReport?.reportID ?? '' : ''),

What alternative solutions did you explore? (Optional)

Pass the full as 3rd param of hasIOUToApproveOrPay and do the checking in there.

In addition, the condition action.childReportID?.toString() !== excludedIOUReportID here should be stricter, if excludedIOUReportID is empty, we should skip checking the action.childReportID?.toString() !== excludedIOUReportID to avoid cases that childReportID and excludedIOUReportID are both empty.

!excludedIOUReportID || action.childReportID?.toString() !== excludedIOUReportID

Additional: I notice that in

hasOutstandingChildRequest: false,
, when paying a request, hasOutstandingChildRequest is always set to false, this is not always true because there could be IOU report that still pending approval. Ideally hasIOUToApproveOrPay should be used here too, like for approval.

@dominictb
Copy link
Contributor

Updated proposal to add some details

@DivyamUp14
Copy link

DivyamUp14 commented Jun 7, 2024

Proposal

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

When partially approving reports we dont have GBR in LHN

What is the root cause of that problem?

In case of partial approval we will always have to show GBR as there will always be some pending approvals after partially approving.
Here we are calculating whether chat have more approvable or payable actions. But in case of partial this should be default be true as there are more pending approvals after the current partial approval.

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

Since for partial approval the pending expenses can be approved we can set hasOutstandingChildRequest to true skipping GBR calculation for partial approvals here like below.

            hasOutstandingChildRequest: full ? hasIOUToApproveOrPay(chatReport, expenseReport?.reportID ?? '') : true,

What alternative solutions did you explore? (Optional)

NA

@dominictb
Copy link
Contributor

dominictb commented Jun 7, 2024

Note: We can directly set this to true and do not need calculate if it partial or full as this part of code is called only for full approval.

@allgandalf IMO since approving full while there's held request is a risky action (questionable request that was held, will be approved), it should always be "default partial", unless the user approves "full" by confirming. In case of this, the user didn't confirm to approve full, so the default should be "partial". That's also how it works now.

@DivyamUp14
Copy link

Currently when user Approves from Report preview all the held transactions are getting unheld.
FYI @allgandalf

@dominictb
Copy link
Contributor

dominictb commented Jun 7, 2024

Currently when user Approves from Report preview all the held transactions are getting unheld.

The optimistic data when offline indicates it's default "partial", not full, same for the held transactions, they are not unheld in offline mode. We need to explicitly pass false as full in that case or default full to false in approveMoneyRequest method definition, so the back-end will recognize it correctly.

Even better, add the confirmation dialog when pressing Approve in confirmation page too, so the user can decide what they want.

Whatever we go with, this will likely be a separate GH issue as the root cause is different and it's happening regardless of this OP issue.

@allgandalf Let us know what you think, if you're confused what "separate issue" this is, I'd be happy to provide more details & screenshots

@DivyamUp14
Copy link

@dominictb I agree this is not handled in offline mode currently but if you approve from Report view it without sending full flag as true even in the API is considered as full payment which in turn changes the transactions which are on hold to unheld.

@allgandalf
Copy link
Contributor

allgandalf commented Jun 9, 2024

Currently when user Approves from Report preview all the held transactions are getting unheld.
FYI @allgandalf

@DivyamUp14 , this is not true, The held transaction is indeed still on hold, it's the UI which is buggy but that is something which would need a completely different issue and detailed conversation. The held requests are still on hold after approving other requests in the same transaction thread.

@DivyamUp14
Copy link

@allgandalf I checked the response data for transaction in the next request after approval and it returns data with transaction with unhold status. In the UI it is not updated because the optimistic data set in approval API is based on the full parameter which is not sent at the time of approving from Request preview

@dominictb
Copy link
Contributor

that is something which would need a completely different issue and detailed conversation

@allgandalf I agree 👍

Especially when

approving full while there's held request is a risky action (because questionable or even fraudulent requests that were held, will be approved), it should always be "default partial", unless the user approves "full" by confirming which is the UX when approving inside the IOU report.

And I don't see any reason why we shouldn't

Even better, add the confirmation dialog when pressing Approve in confirmation page too, so the user can decide what they want.

@allgandalf Do you think we should open a Slack thread to discuss this? I'd be happy to help start it if we should.

Meanwhile we can continue to evaluate proposals for the OP issue, the above will be handled as a separate issue after the discussion.

@allgandalf
Copy link
Contributor

@johncschuster , I was 😷 last few days so worked low key, feeling much better now, will review the proposals this week for sure, I just need to get one thing cleared about this issue about this comment, when i tested even though the UI didn't show any held request when i clicked approved for that single held expense, i was prompted with the approve partial/full prompt, so I will test again tomorrow and then review proposals above , thanks and sorry for the delay

@johncschuster
Copy link
Contributor

No worries, @allgandalf! Thanks for the update! I hope you're feeling better!

@melvin-bot melvin-bot bot added the Overdue label Jun 12, 2024
@johncschuster
Copy link
Contributor

@allgandalf what's the latest here? Were you able to test this again?

@melvin-bot melvin-bot bot removed the Overdue label Jun 12, 2024
@allgandalf
Copy link
Contributor

allgandalf commented Jun 13, 2024

sorry for the delay reviewed another high priority PR yesterday.

I do get a GBR when i approve expense, followed the OP steps:

Screen.Recording.2024-06-13.at.9.23.29.AM.mov

is anyone from the contributor able to reproduce it? if yes can you please attach a video of the steps followed :)

Good times 🥂

@DivyamUp14
Copy link

@allgandalf the issue is with data not being optimistically set, Once you approve the GBR disappears and then after the API response it shows up.

Copy link

melvin-bot bot commented Jun 18, 2024

📣 @dominictb 🎉 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 📖

@blimpich
Copy link
Contributor

@dominictb @DivyamUp14 thank you both for carefully approaching this problem and explaining your solutions. It was very easy for me to read through this issue comment by comment and understand what was going on. Great work!

@dominictb congrats on having the selected proposal, feel free to raise a PR.

@allgandalf thank you for carefully considering and testing the proposals for regressions. Feel free to tag me in discussions related to that bug you found and I can make sure we create an issue and look into it.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Jun 20, 2024
@johncschuster
Copy link
Contributor

Deployed to staging 3 days ago 👍 I'll issue payment once it clears the waiting period.

@johncschuster
Copy link
Contributor

It's been 6 days since deployed to staging. We're almost there.

@johncschuster
Copy link
Contributor

@blimpich I noticed the PR linked above was deployed a week ago to staging, but hasn't yet been deployed to production. Do you know why we haven't deployed it yet?

@allgandalf
Copy link
Contributor

That should indeed be deployed to production the deploy list associated was closed 5 days back, My guess is automation failed

@johncschuster
Copy link
Contributor

@allgandalf I'm not quite following. Are you saying the PR has been deployed to production, but there's no comment making that known, or are you saying it hasn't been deployed to production because an automation may have failed?

@allgandalf
Copy link
Contributor

yes the PR has been deployed to production, the updated code exists on the production branch:

hasOutstandingChildRequest: hasIOUToApproveOrPay(chatReport, full ? expenseReport?.reportID ?? '-1' : '-1'),

Can you please pay this out :)

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jul 3, 2024
@melvin-bot melvin-bot bot changed the title [$250] Partial approved reports don’t have GBR in the LHN [HOLD for payment 2024-07-10] [$250] Partial approved reports don’t have GBR in the LHN Jul 3, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 3, 2024
Copy link

melvin-bot bot commented Jul 3, 2024

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

Copy link

melvin-bot bot commented Jul 3, 2024

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

If no regressions arise, payment will be issued on 2024-07-10. 🎊

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

Copy link

melvin-bot bot commented Jul 3, 2024

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:

  • [@allgandalf] The PR that introduced the bug has been identified. Link to the PR:
  • [@allgandalf] 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:
  • [@allgandalf] 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:
  • [@allgandalf] Determine if we should create a regression test for this bug.
  • [@allgandalf] 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.
  • [@johncschuster] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@allgandalf
Copy link
Contributor

Melvin 🙃, this is ready for payment, the PR was deployed to production in the last release and not this!!!

@johncschuster
Copy link
Contributor

Thanks for calling out that the code has been deployed to prod, @allgandalf. I've issued payment!

Can you please complete the BZ Checklist above?

@allgandalf
Copy link
Contributor

allgandalf commented Jul 10, 2024

Regression Test Proposal

  1. Create a Collect workspace with user A (member) and user B (admin).
  2. Enable approvals and have user B approve for user A
  3. Have user A create several expenses
  4. As user B, hold one of the expenses
  5. Click approve and choose to partial approve what isn’t held
  6. Verify that: The newly created report for the held expense is GBR’ed in the LHN

Do we agree 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
No open projects
Archived in project
Development

No branches or pull requests

7 participants