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

[C+ Checklist Needs Completion] [$500] IOU - Approve button appears while approvals is disabled #39171

Closed
3 of 6 tasks
izarutskaya opened this issue Mar 28, 2024 · 41 comments
Closed
3 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

@izarutskaya
Copy link

izarutskaya commented Mar 28, 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.57-2
Reproducible in staging?: Y
Reproducible in production?: Y
Found when executing PR : #38253
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team

Action Performed:

Pre-requisites:
Have a collect WS and make chat enabled on ND
Have 2 accounts (one admin, one employee)
Having `Make or track payments enabled
Toggle on delay submissions on ND (Logged in as the admin)
Toggle off Add approvals
On OD Make reimbursement direct with a VBBA

  1. [Employee] Request money from the workspace chat and submit it
  2. [Admin] Click on the IOU preview and observe the header

Expected Result:

"Pay with expensify" button should show up since this is the case where Delay submissions is enabled and approvals is disabled

Actual Result:

"Approve" button appears on the header

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

Bug6429854_1711614962501.Screen_Recording_20240328_112744_Chrome.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~014fc34bb4b2bfbb10
  • Upwork Job ID: 1773511332097155072
  • Last Price Increase: 2024-03-29
  • Automatic offers:
    • DylanDylann | Reviewer | 103218707
Issue OwnerCurrent Issue Owner: @greg-schroeder
@izarutskaya izarutskaya added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Mar 28, 2024
Copy link

melvin-bot bot commented Mar 28, 2024

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

@izarutskaya
Copy link
Author

We think this issue might be related to the #collect project.

@allgandalf
Copy link
Contributor

allgandalf commented Mar 28, 2024

Proposal

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

Approve button appears even when approvals are not required

What is the root cause of that problem?

In canApproveIOU we do not check if the approvalMode and autoReportingFrequency are optional:

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

App/src/libs/actions/IOU.ts

Lines 4523 to 4524 in 4fbd218

return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled;
}

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

Add a check in canApproveIOU to check if the approval mode and delay submittion are Optional and if it is then return the value:

diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts
index b67e44fcf5..c361ed3e5e 100644
--- a/src/libs/actions/IOU.ts
+++ b/src/libs/actions/IOU.ts
@@ -4519,8 +4519,10 @@ function canApproveIOU(iouReport: OnyxEntry<OnyxTypes.Report> | EmptyObject, cha
     const isOpenExpenseReport = isPolicyExpenseChat && ReportUtils.isOpenExpenseReport(iouReport);
     const isApproved = ReportUtils.isReportApproved(iouReport);
     const iouSettled = ReportUtils.isSettled(iouReport?.reportID);
+    const isApprovalOptional = policy?.approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL;
+    const canDelaySubmissions = policy?.autoReportingFrequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCY.IMMEDIATE &&  policy?.autoReportingFrequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCY.INSTANT;
 
-    return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled;
+    return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled && !(isApprovalOptional && canDelaySubmissions);
 }

What alternative solutions did you explore? (Optional)

N/A

@bernhardoj
Copy link
Contributor

Proposal

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

The approve button is still displayed even though the add approvals option is disabled.

What is the root cause of that problem?

We already have a condition here to not show the approve button if the approval is disabled (isOnSubmitAndClosePolicy).

App/src/libs/actions/IOU.ts

Lines 4509 to 4513 in 4fbd218

const isOnInstantSubmitPolicy = PolicyUtils.isInstantSubmitEnabled(policy);
const isOnSubmitAndClosePolicy = PolicyUtils.isSubmitAndClose(policy);
if (isOnInstantSubmitPolicy && isOnSubmitAndClosePolicy) {
return false;
}

However, the auto-reporting frequency needs to be instant (isOnInstantSubmitPolicy) to not show the approval button. In our case, the frequency is set to WEEKLY, so the condition is never met.

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

Change the condition to accept either isOnInstantSubmitPolicy or isOnSubmitAndClosePolicy.

if (isOnInstantSubmitPolicy || isOnSubmitAndClosePolicy) {

Or we can remove isOnInstantSubmitPolicy

@greg-schroeder greg-schroeder added the External Added to denote the issue can be worked on by a contributor label Mar 29, 2024
@melvin-bot melvin-bot bot changed the title IOU - Approve button appears while approvals is disabled [$500] IOU - Approve button appears while approvals is disabled Mar 29, 2024
Copy link

melvin-bot bot commented Mar 29, 2024

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

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

melvin-bot bot commented Mar 29, 2024

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

@melvin-bot melvin-bot bot added the Overdue label Apr 1, 2024
@DylanDylann
Copy link
Contributor

@bernhardoj's proposal looks good to me

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Apr 1, 2024

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

@stitesExpensify
Copy link
Contributor

@bernhardoj do you know why we initially implemented it to only be disabled when isOnInstantSubmitPolicy? That seems like it was done intentionally, and I just want to make sure we aren't going to break something

@bernhardoj
Copy link
Contributor

It was first implemented in #35470, but looks like in this PR #38253 (where the QA found the issue), the test step expect the approve button to not show.

cc: @luacmartins @lakchote

@luacmartins
Copy link
Contributor

We should not show the approve button if approvals are disabled

@DylanDylann
Copy link
Contributor

@luacmartins As mentioned here

Approver shouldn't be able to "Approve" an expense report IFF the report's policy is a Collect Policy, on "Instant Submit" reporting frequency, with "Submit & Close" approval mode.

Do we want to display the Approve button if users are in approval mode and not in "Instant Submit" reporting frequency

cc @Beamanator

@Beamanator
Copy link
Contributor

Beamanator commented Apr 3, 2024

Approver shouldn't be able to "Approve" an expense report IFF the report's policy is a Collect Policy, on "Instant Submit" reporting frequency, with "Submit & Close" approval mode.

Agreed (I wrote that lol)

Do we want to display the Approve button if users are in approval mode and not in "Instant Submit" reporting frequency

To be clear, you're asking "if users are in approval mode Submit & Close", right? I believe in that case we wouldn't want to show the "Approve" button either

Because "Submit & Close" basically means: After a submitter submits a report, what next? We close the report, we don't wait for the admin to Approve it

@bernhardoj
Copy link
Contributor

Because "Submit & Close" basically means: After a submitter submits a report, what next? We close the report, we don't wait for the admin to Approve it

That makes sense, but currently, the condition expects the instant submit is on too to hide the approve button.

App/src/libs/actions/IOU.ts

Lines 4599 to 4601 in ebc8de8

if (isOnInstantSubmitPolicy && isOnSubmitAndClosePolicy) {
return false;
}

I think it makes sense if we remove the instant submit condition because whether it's an instant or manual submit, the report will be closed immediately, right?

@Beamanator
Copy link
Contributor

I tentatively think that definitely makes sense 😅 👍

@melvin-bot melvin-bot bot added the Overdue label Apr 5, 2024
@greg-schroeder
Copy link
Contributor

Discussion continues here - @stitesExpensify @Beamanator we cool with @bernhardoj's approach to solve this one?

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Apr 5, 2024
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 22, 2024
Copy link

melvin-bot bot commented Jul 22, 2024

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

PR is ready

cc: @DylanDylann

@greg-schroeder
Copy link
Contributor

PR is being reviewed

@greg-schroeder greg-schroeder removed the retest-weekly Apply this label if you want this issue tested on a Weekly basis by Applause label Jul 25, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Aug 2, 2024
@melvin-bot melvin-bot bot changed the title [$500] IOU - Approve button appears while approvals is disabled [HOLD for payment 2024-08-09] [$500] IOU - Approve button appears while approvals is disabled Aug 2, 2024
Copy link

melvin-bot bot commented Aug 2, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Aug 2, 2024
Copy link

melvin-bot bot commented Aug 2, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.15-9 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-08-09. 🎊

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

Copy link

melvin-bot bot commented Aug 2, 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:

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

@greg-schroeder
Copy link
Contributor

Payment summary:

Contributor: @bernhardoj - $500 - You can make a manual request
C+: @DylanDylann - $500 - Paying through Upwork

@greg-schroeder
Copy link
Contributor

Please complete the checklist @DylanDylann when you're able!

@greg-schroeder greg-schroeder changed the title [HOLD for payment 2024-08-09] [$500] IOU - Approve button appears while approvals is disabled [C+ Checklist Needs Completion] [$500] IOU - Approve button appears while approvals is disabled Aug 8, 2024
@bernhardoj
Copy link
Contributor

Requested in ND.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Aug 8, 2024
@JmillsExpensify
Copy link

$500 approved for @bernhardoj

@DylanDylann
Copy link
Contributor

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:

[@DylanDylann] The PR that introduced the bug has been identified. Link to the PR: #35470
[@DylanDylann] 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: The author explained here
[@DylanDylann] 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: NA
[@DylanDylann] Determine if we should create a regression test for this bug. Yes
[@DylanDylann] 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

Prerequisite: Admin has a collect workspace and turns off the approval and sets the Delayed submission to MANUAL (or other than INSTANT)

  1. As an employee, add a money request and submit it to the workspace expense chat
  2. As the admin, open the workspace chat (refresh or reopen the app if needed to get the latest data)
  3. Verify the pay button shows instead of the approve button on the report preview

Do we agree 👍 or 👎

@melvin-bot melvin-bot bot added the Overdue label Aug 12, 2024
@greg-schroeder
Copy link
Contributor

Filed regression test, closing

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