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

[$250] "Approve" button appears even if the report has a violation on it #50479

Closed
1 of 6 tasks
m-natarajan opened this issue Oct 8, 2024 · 33 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 Oct 8, 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: 9.0.46-2
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: @coleaeason
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1728406913463479

Action Performed:

  1. Submit an expense report with violation
  2. Sign in as a approver

Expected Result:

Should not see a "approve" button since receipt has a violation

Actual Result:

"Approve" button with GBR appears

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

Screenshot 2024-10-08 at 1 01 13 PM
Snip - (3) New Expensify - Google Chrome

Add any screenshot/video evidence

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021845657010504568512
  • Upwork Job ID: 1845657010504568512
  • Last Price Increase: 2024-10-14
  • Automatic offers:
    • hoangzinh | Reviewer | 104460235
    • abzokhattab | Contributor | 104460238
Issue OwnerCurrent Issue Owner: @adelekennedy
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 8, 2024
Copy link

melvin-bot bot commented Oct 8, 2024

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.

@abzokhattab
Copy link
Contributor

abzokhattab commented Oct 8, 2024

Edited by proposal-police: This proposal was edited at 2024-10-08 20:05:37 UTC.

Proposal

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

The "Approve" button appears even when the report has a violation.

What is the root cause of that problem?

The canApprove function does not consider whether the report has violations.

App/src/libs/actions/IOU.ts

Lines 6905 to 6926 in fd32223

function canApproveIOU(iouReport: OnyxTypes.OnyxInputOrEntry<OnyxTypes.Report>, policy: OnyxTypes.OnyxInputOrEntry<OnyxTypes.Policy>) {
// Only expense reports can be approved
const isPaidGroupPolicy = policy && PolicyUtils.isPaidGroupPolicy(policy);
if (!isPaidGroupPolicy) {
return false;
}
const isOnSubmitAndClosePolicy = PolicyUtils.isSubmitAndClose(policy);
if (isOnSubmitAndClosePolicy) {
return false;
}
const managerID = iouReport?.managerID ?? -1;
const isCurrentUserManager = managerID === userAccountID;
const isOpenExpenseReport = ReportUtils.isOpenExpenseReport(iouReport);
const isApproved = ReportUtils.isReportApproved(iouReport);
const iouSettled = ReportUtils.isSettled(iouReport?.reportID);
const reportNameValuePairs = ReportUtils.getReportNameValuePairs(iouReport?.reportID);
const isArchivedReport = ReportUtils.isArchivedRoom(iouReport, reportNameValuePairs);
return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled && !isArchivedReport;
}

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

We should update the return statement to add a condition to check that there are no violations:

return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled && !isArchivedReport && !hasReportViolations(iouReport?.reportID)

the same change can be done in other iou actions if needed.

What alternative solutions did you explore? (Optional)

optionally we can useReportUtils.hasViolations(iouReport?.reportID ?? "", transactionsViolations) instead of hasReportViolations(iouReport?.reportID) where the transactionsViolations can either be passed to the function using Onyx:

const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);

Or, it can be declared as a global variable within the file, with the value fetched using Onyx.connect to the ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS key.

@ChavdaSachin
Copy link
Contributor

ChavdaSachin commented Oct 8, 2024

Edited by proposal-police: This proposal was edited at 2024-10-08 20:21:18 UTC.

Proposal

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

"Approve" button appears even if the report has a violation on it

What is the root cause of that problem?

We do not check for Violations to display or disable approve button.

const shouldShowApproveButton = useMemo(() => IOU.canApproveIOU(iouReport, policy), [iouReport, policy]);
const shouldDisableApproveButton = shouldShowApproveButton && !ReportUtils.isAllowedToApproveExpenseReport(iouReport);

const shouldShowApproveButton = useMemo(() => IOU.canApproveIOU(moneyRequestReport, policy), [moneyRequestReport, policy]);
const shouldDisableApproveButton = shouldShowApproveButton && !ReportUtils.isAllowedToApproveExpenseReport(moneyRequestReport);

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

Add violation check for approve button same as submit button here.

const shouldShowSubmitButton = isOpenExpenseReport && reimbursableSpend !== 0 && !showRTERViolationMessage;

Append && !showRTERViolationMessage here(based of if we want to hide or disable the button)
const shouldShowApproveButton = useMemo(() => IOU.canApproveIOU(iouReport, policy), [iouReport, policy]);
const shouldDisableApproveButton = shouldShowApproveButton && !ReportUtils.isAllowedToApproveExpenseReport(iouReport);

And Append && !hasAllPendingRTERViolations here(based of if we want to hide or disable the button)
const shouldShowApproveButton = useMemo(() => IOU.canApproveIOU(moneyRequestReport, policy), [moneyRequestReport, policy]);
const shouldDisableApproveButton = shouldShowApproveButton && !ReportUtils.isAllowedToApproveExpenseReport(moneyRequestReport);

Note

by using this check we would only stop approval if violationType==='RTER' same as submit button ,
if we want to stop user for violationType==='Notice' use additional check using TransactionUtils.hasNoticeTypeViolation()
for violationType==='Warning' use additional check using TransactionUtils.hasWarningTypeViolation()
for violationType==='Violation' use additional check using TransactionUtils.hasViolation()
IMO these we should add check for violationType==='Violation' and ignore warningType and noticeType.

Optionally we could also implement the same for the submit button so employee could not submit the expense with the violation in the first place.

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.

@ChavdaSachin
Copy link
Contributor

Updated proposal
added important info in Note section

@melvin-bot melvin-bot bot added the Overdue label Oct 11, 2024
@adelekennedy adelekennedy added the External Added to denote the issue can be worked on by a contributor label Oct 14, 2024
@melvin-bot melvin-bot bot changed the title "Approve" button appears even if the report has a violation on it [$250] "Approve" button appears even if the report has a violation on it Oct 14, 2024
Copy link

melvin-bot bot commented Oct 14, 2024

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

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

melvin-bot bot commented Oct 14, 2024

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

@hoangzinh
Copy link
Contributor

Thank you for your proposals, everyone. I think @abzokhattab's proposal looks good to me. Both proposals pointed out root cause exactly, but @abzokhattab's solution (alternative) avoids repeat condition check violations (DRY)

Link to proposal #50479 (comment)

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Oct 15, 2024

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

@ChavdaSachin
Copy link
Contributor

@hoangzinh I agree we could make changes to canApproveIOU function if we only want to make changes to approve button and still let user submit without any restriction.
Curious, do we want to only prevent approvals? or should we prevent submissions as well?

@hoangzinh
Copy link
Contributor

Curious, do we want to only prevent approvals? or should we prevent submissions as well?

It's a good call. I will let @Gonals decide on it but in my opinion, because we haven't had an issue with the "submit" button so I think it's fine with the current violation checking for that button 👀 (I'm unsure besides RTERViolation, do we have any violations that can occur before a requester submit an expense)

@Gonals
Copy link
Contributor

Gonals commented Oct 17, 2024

Curious, do we want to only prevent approvals? or should we prevent submissions as well?

It's a good call. I will let @Gonals decide on it but in my opinion, because we haven't had an issue with the "submit" button so I think it's fine with the current violation checking for that button 👀 (I'm unsure besides RTERViolation, do we have any violations that can occur before a requester submit an expense)

Agreed 👍

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

melvin-bot bot commented Oct 17, 2024

📣 @hoangzinh 🎉 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 Oct 17, 2024

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

@ChavdaSachin
Copy link
Contributor

One more point I missed to inform - the date violation shown in video does not fall under RTERViolations.

@dylanexpensify dylanexpensify moved this to Release 3: Fall 2024 (Nov) in [#whatsnext] #expense Oct 18, 2024
@melvin-bot melvin-bot bot added the Reviewing Has a PR in review label Oct 19, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production labels Nov 28, 2024
@melvin-bot melvin-bot bot changed the title [$250] "Approve" button appears even if the report has a violation on it [HOLD for payment 2024-12-05] [$250] "Approve" button appears even if the report has a violation on it Nov 28, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Nov 28, 2024
Copy link

melvin-bot bot commented Nov 28, 2024

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

Copy link

melvin-bot bot commented Nov 28, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.67-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-12-05. 🎊

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

Copy link

melvin-bot bot commented Nov 28, 2024

@hoangzinh @adelekennedy @hoangzinh The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Nov 30, 2024
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2024-12-05] [$250] "Approve" button appears even if the report has a violation on it [HOLD for payment 2024-12-07] [HOLD for payment 2024-12-05] [$250] "Approve" button appears even if the report has a violation on it Nov 30, 2024
Copy link

melvin-bot bot commented Nov 30, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.68-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-12-07. 🎊

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

Copy link

melvin-bot bot commented Nov 30, 2024

@hoangzinh @adelekennedy @hoangzinh The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

@mountiny mountiny changed the title [HOLD for payment 2024-12-07] [HOLD for payment 2024-12-05] [$250] "Approve" button appears even if the report has a violation on it [$250] "Approve" button appears even if the report has a violation on it Dec 3, 2024
@mountiny mountiny removed the Awaiting Payment Auto-added when associated PR is deployed to production label Dec 3, 2024
@garrettmknight garrettmknight added the Awaiting Payment Auto-added when associated PR is deployed to production label Dec 4, 2024
@melvin-bot melvin-bot bot added Overdue Daily KSv2 and removed Weekly KSv2 Overdue labels Dec 9, 2024
Copy link

melvin-bot bot commented Dec 16, 2024

@hoangzinh, @Gonals, @abzokhattab, @adelekennedy Huh... This is 4 days overdue. Who can take care of this?

@hoangzinh
Copy link
Contributor

@adelekennedy
Copy link

I think we want to close here - but payment is still due

@melvin-bot melvin-bot bot removed the Overdue label Dec 18, 2024
@hoangzinh
Copy link
Contributor

Agree @adelekennedy

@melvin-bot melvin-bot bot added the Overdue label Dec 20, 2024
@adelekennedy
Copy link

Upwork payments made - closing

@github-project-automation github-project-automation bot moved this from Bugs and Follow Up Issues to Done in [#whatsnext] #expense Dec 20, 2024
@melvin-bot melvin-bot bot removed the Overdue label Dec 20, 2024
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
Status: Done
Development

No branches or pull requests

10 participants