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

Expense - Approve button appears when "Add approvals" is disabled on Submit and Close policy #45846

Closed
6 tasks done
m-natarajan opened this issue Jul 20, 2024 · 4 comments
Closed
6 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Overdue

Comments

@m-natarajan
Copy link

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Issue found when validating #45568
Version Number: 9.0.10-2
Reproducible in staging?: y
Reproducible in production?: n
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: Applause internal team
Slack conversation:

Action Performed:

Precondition:

  • Admin and employee are in the same workspace.
  • Workflows feature is enabled.
  • Delay submissions is enabled and set to Weekly.
  • Add approvals is disabled.
  1. Go to staging.new.expensify.com
  2. [Employee] Go to worrkspace chat.
  3. [Employee] Submit an expense to the workspace chat.
  4. [Employee] Click on the submit button on expense preview.
  5. [Admin] Go to the expense submitted by employee.
  6. [Admin] Click Approve.

Expected Result:

Since "Add approvals" is disabled, Approve button should not show up for Admin.

Actual Result:

Approve button shows up for Admin when "Add approvals" is disabled.
Error shows up when trying to approve the report.

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

Bug6548154_1721487331308.20240720_225009.mp4

View all open jobs on GitHub

@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 20, 2024
Copy link

melvin-bot bot commented Jul 20, 2024

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

@c3024
Copy link
Contributor

c3024 commented Jul 21, 2024

Proposal

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

Approval option is displayed for admin when Add approvals is toggled to off in Workflows

What is the root cause of that problem?

We show approve button when shouldHidePaymentOptions and shouldShowApproveButton are true

if (shouldHidePaymentOptions && shouldShowApproveButton) {
return [approveButtonOption];

shouldHidePaymentOptions is true when shouldShowPayButton is false
shouldHidePaymentOptions={!shouldShowPayButton}

shouldShowPayButton is false when canIOUBePaid is false
const shouldShowPayButton = useMemo(() => IOU.canIOUBePaid(iouReport, chatReport, policy), [iouReport, chatReport, policy]);

canIOUBePaid is false when shouldBeApproved (or canApproveIOU) is true among other conditions

App/src/libs/actions/IOU.ts

Lines 6441 to 6444 in f3a8f73

const shouldBeApproved = canApproveIOU(iouReport, chatReport, policy);
return (
isPayer && !isOpenExpenseReport && !iouSettled && !iouReport?.isWaitingOnBankAccount && reimbursableSpend !== 0 && !isChatReportArchived && !isAutoReimbursable && !shouldBeApproved

canApproveIOU should be false for submit and close policies

App/src/libs/actions/IOU.ts

Lines 6383 to 6386 in f3a8f73

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

but this checks for isOnInstantSubmitPolicy as well and this returns false and it falls to later conditions and returns true.
The isOnInstantSubmitPolicy check is for submitters and should be irrelevant to checking canApproveIOU.
isSubmitAndClose checks for the optional approval here
return policy?.approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL;

so that check alone should be here.

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

Remove the isOnInstantSubmitPolicy check here

App/src/libs/actions/IOU.ts

Lines 6383 to 6385 in f3a8f73

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

What alternative solutions did you explore? (Optional)

@bernhardoj
Copy link
Contributor

Looks like this is the same as #39171

@OfstadC
Copy link
Contributor

OfstadC commented Jul 22, 2024

Going to close since this is a duplicate

@OfstadC OfstadC closed this as completed Jul 22, 2024
@melvin-bot melvin-bot bot added the Overdue label Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Overdue
Projects
None yet
Development

No branches or pull requests

4 participants