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-04-15] [$500] Expense - Approve button appears in archived expense report #38229

Closed
5 of 6 tasks
kbecciv opened this issue Mar 13, 2024 · 28 comments
Closed
5 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

@kbecciv
Copy link

kbecciv commented Mar 13, 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.51-3
Reproducible in staging?: y
Reproducible in production?: y
Issue reported by: Applause - Internal Team

Action Performed:

Precondition:

  • Admin and employee are in the Collect workspace.
  • The Approval mode in the Collect workspace is Submit and Close.
  1. Go to staging.new.expensify.com.
  2. [Employee] Create a manual request in the workspace chat.
  3. [Employee] Submit the report,
  4. [Admin] Go to workspace chat with employee.
  5. [Admin] Click Approve button.
  6. [Admin] Click on the header subtitle to return to main chat.
  7. {Admin] Click on expense preview to go to expense report.

Expected Result:

In Step 5, Approve button should not appear in expense report since the expense report is archived.

Actual Result:

In Step 5, Approve button appears in expense report when the expense report is archived.
When clicking Approve button, the expense report is no longer archived and back to archived state when reopening expense report (Step 7).

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

Add any screenshot/video evidence

Bug6411984_1710315334923.bandicam_2024-03-13_15-27-32-588.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01d56509b7da773540
  • Upwork Job ID: 1769820596774514688
  • Last Price Increase: 2024-03-25
  • Automatic offers:
    • Ollyws | Reviewer | 0
    • rojiphil | Contributor | 0
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Mar 13, 2024
Copy link

melvin-bot bot commented Mar 13, 2024

Triggered auto assignment to @slafortune (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@kbecciv
Copy link
Author

kbecciv commented Mar 13, 2024

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

@Krishna2323
Copy link
Contributor

Krishna2323 commented Mar 13, 2024

Proposal

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

Expense - Approve button appears in archived expense report

What is the root cause of that problem?

Previous RCA

We don't check if the report is archived or not before determining valued for canIOUBePaid & canApproveIOU util functions.

return isPayer && !isOpenExpenseReport && !iouSettled && !iouReport?.isWaitingOnBankAccount && reimbursableSpend !== 0 && !iouCanceled && !isAutoReimbursable;

function canApproveIOU(iouReport: OnyxEntry<OnyxTypes.Report> | EmptyObject, chatReport: OnyxEntry<OnyxTypes.Report> | EmptyObject, policy: OnyxEntry<OnyxTypes.Policy> | EmptyObject) {

In canApproveIOU we don't check for ReportUtils.isArchivedRoom(chatReport) before returning the value. We do check for ReportUtils.isArchivedRoom(chatReport) in canIOUBePaid, we just need to do the same for canApproveIOU.

function canApproveIOU(iouReport: OnyxEntry<OnyxTypes.Report> | EmptyObject, chatReport: OnyxEntry<OnyxTypes.Report> | EmptyObject, policy: OnyxEntry<OnyxTypes.Policy> | EmptyObject) {

Result

const iouCanceled = ReportUtils.isArchivedRoom(chatReport);

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

Add !ReportUtils.isArchivedRoom(props.report) to canApproveIOU util function.

Alternatively

Add !ReportUtils.isArchivedRoom(props.report) check here

const shouldShowSettlementButton = shouldShowPayButton || shouldShowApproveButton;

Or add the check here:

function isSettled(reportID: string | undefined): boolean {

@Krishna2323
Copy link
Contributor

Proposal Updated

@rojiphil
Copy link
Contributor

Proposal

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

When the approval mode is set to Submit and Close, submitting an Expense Report shows the Approve button.

What is the root cause of that problem?

The root cause is that we have not yet handled the Submit and Close approval mode when the report is submitted.

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

To begin with, we need to handle the Submit and Close approval mode while submitting the report here. For this, we can set the statusNum to CLOSED and stateNum to APPROVED if the approval mode is Submit and Close like this here. This will ensure compliance with offline pattern.

const isSubmitAndClosePolicy = PolicyUtils.isSubmitAndClose(policy);
…
stateNum: isSubmitAndClosePolicy ? CONST.REPORT.STATE_NUM.APPROVED : CONST.REPORT.STATE_NUM.SUBMITTED,
statusNum: isSubmitAndClosePolicy ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.SUBMITTED,

Also, we need to optimistically generate the next step for the submitted state only when it is not in the Submit and Close approval mode. This is because BE does not display the submitted next step for Submit and Close approval mode.

Further, we decide on whether Approve button is required to be displayed or not here. Here, additionally, we also have to check if the report is in an approved and closed state like this here

const isArchivedReport = ReportUtils.isArchivedRoom(report);
return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled && !isArchivedReport;

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Mar 15, 2024
Copy link

melvin-bot bot commented Mar 18, 2024

@slafortune Huh... This is 4 days overdue. Who can take care of this?

@slafortune
Copy link
Contributor

Submit and close should not/doesn't need to show the Approve button - Adding to #wavecollect

@melvin-bot melvin-bot bot removed the Overdue label Mar 18, 2024
@slafortune slafortune added External Added to denote the issue can be worked on by a contributor Overdue labels Mar 18, 2024
@melvin-bot melvin-bot bot changed the title Expense - Approve button appears in archived expense report [$500] Expense - Approve button appears in archived expense report Mar 18, 2024
Copy link

melvin-bot bot commented Mar 18, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 18, 2024
Copy link

melvin-bot bot commented Mar 18, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label Mar 18, 2024
@allgandalf
Copy link
Contributor

Proposal

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

What is the root cause of that problem?

Note

The question here is not whether one can approve the IOU report or not, but it is to show the Approve button or not, canApproveIOU is the ability of the admin/employee to approve the policy request

For shouldShowApproveButton we forget to check whether the room is archived or not:

const shouldShowApproveButton = useMemo(() => IOU.canApproveIOU(moneyRequestReport, chatReport, policy), [moneyRequestReport, chatReport, policy]);

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

Update shouldShowApproveButton as follows to check if the policy is archived or not:

const shouldShowApproveButton = useMemo(() => IOU.canApproveIOU(moneyRequestReport, chatReport, policy) 
- , [moneyRequestReport, chatReport, policy]);
+ && !ReportUtils.isArchivedRoom(moneyRequestReport), [moneyRequestReport, chatReport, policy]);

Note

We don't need to update shouldShowPayButton as the util used over there already checks for archived policies and returns false accordingly, Also adding the archive check at shouldShowSettlementButton would not have any effect and the approve button would still be seen as shouldShowApproveButton and shouldShowSettlementButton are both used for different purposes, Also shouldShowSettlementButton will automatically become false if the workspace is archived if we make shouldShowApproveButton false as well.

What alternative solutions did you explore? (Optional)

N/A

@Ollyws
Copy link
Contributor

Ollyws commented Mar 20, 2024

Couldn't get to these today but will review tomorrow.

@allgandalf
Copy link
Contributor

friendly bump @Ollyws for review :)

@Ollyws
Copy link
Contributor

Ollyws commented Mar 22, 2024

As far as I can see, the report is immediately archived by the backend when the report is submitted meaning all we have to do here is hide the approve button for archived reports.

@rojiphil Could you expand on why your changes to submitReport would be necessary here?

@rojiphil
Copy link
Contributor

Could you expand on why your changes to submitReport would be necessary here?

@Ollyws I agree that the report gets archived immediately by BE when the report is submitted in Submit and Close approval mode. But that's when it is online. When offline, changes to submitReport would be necessary to ensure that the app behaves as expected in Submit and Close approval mode. Hope this answer your query.

@Ollyws
Copy link
Contributor

Ollyws commented Mar 23, 2024

@rojiphil But the report is archived agnostically, I can't see a situation in which the changes to submitReport would be necessary but maybe I'm missing something?

@rojiphil
Copy link
Contributor

But the report is archived agnostically, I can't see a situation in which the changes to submitReport would be necessary but maybe I'm missing something?

@Ollyws Sorry. I could have done better in communication here. I think changes to submitReport become necessary when the submitter and approver are the same user. Here is a test video for the same. Let me know if this is still not clear.

38229-Issue.mp4

@Ollyws
Copy link
Contributor

Ollyws commented Mar 25, 2024

Ah yes thanks for clearing that up.
@rojiphil's proposal LGTM.

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Mar 25, 2024

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

Copy link

melvin-bot bot commented Mar 25, 2024

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

@robertjchen
Copy link
Contributor

Thanks for the discussion, and I also agree with the proposal 👍

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 25, 2024
Copy link

melvin-bot bot commented Mar 25, 2024

📣 @Ollyws 🎉 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

Copy link

melvin-bot bot commented Mar 25, 2024

📣 @rojiphil 🎉 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 melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Mar 27, 2024
@rojiphil
Copy link
Contributor

@Ollyws PR is ready for review.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Apr 8, 2024
@melvin-bot melvin-bot bot changed the title [$500] Expense - Approve button appears in archived expense report [HOLD for payment 2024-04-15] [$500] Expense - Approve button appears in archived expense report Apr 8, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Apr 8, 2024
Copy link

melvin-bot bot commented Apr 8, 2024

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

Copy link

melvin-bot bot commented Apr 8, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.60-13 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-04-15. 🎊

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

Copy link

melvin-bot bot commented Apr 8, 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:

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

@Ollyws
Copy link
Contributor

Ollyws commented Apr 14, 2024

BugZero Checklist:

  • The PR that introduced the bug has been identified. Link to the PR:

This wasn't introduced by any PR we just hadn't yet handled the 'Submit and close' approval mode on the front-end.

  • 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:

N/A

  • 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:

N/A

  • Determine if we should create a regression test for this bug.

Yes.

  • 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 Proposal

Precondition: Create a collect workspace with Submit and Close approval mode.

1. [Employee]: Create a money request in the Collect workspace.
2. [Admin]: Navigate to the workspace chat with the employee
3. [Admin]: Verify that the report preview is seen with Submit button for the money request created in step 1.
4. [Admin]: Click on Submit button.
5. [Admin]: Verify that Approve button is not displayed in the report preview (Test 1)
6. [Admin]: Navigate to the expense report
7. [Admin]: Verify that the expense report header does not show Approve button (Test 2)
8. [Admin]: Verify that the expense report footer shows that it is archived. (Test 3)

Do we agree 👍 or 👎

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Apr 14, 2024
@slafortune
Copy link
Contributor

@rojiphil Contributor PAID
@Ollyws Reviewer PAID

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
Archived in project
Development

No branches or pull requests

7 participants