Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.29k stars 2.72k forks source link

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

Closed m-natarajan closed 1 month ago

m-natarajan commented 1 month ago

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 https://github.com/Expensify/App/pull/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:

  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?

Screenshots/Videos

https://github.com/user-attachments/assets/d6c203fc-7b45-4885-a623-ea17821223ab

View all open jobs on GitHub

melvin-bot[bot] commented 1 month ago

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 commented 1 month ago

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 https://github.com/Expensify/App/blob/f3a8f736208166286e6f7da3562f1503d5ef2a3d/src/components/SettlementButton.tsx#L187-L188 shouldHidePaymentOptions is true when shouldShowPayButton is false https://github.com/Expensify/App/blob/f3a8f736208166286e6f7da3562f1503d5ef2a3d/src/components/ReportActionItem/ReportPreview.tsx#L440 shouldShowPayButton is false when canIOUBePaid is false https://github.com/Expensify/App/blob/f3a8f736208166286e6f7da3562f1503d5ef2a3d/src/components/ReportActionItem/ReportPreview.tsx#L280 canIOUBePaid is false when shouldBeApproved (or canApproveIOU) is true among other conditions https://github.com/Expensify/App/blob/f3a8f736208166286e6f7da3562f1503d5ef2a3d/src/libs/actions/IOU.ts#L6441-L6444 canApproveIOU should be false for submit and close policies https://github.com/Expensify/App/blob/f3a8f736208166286e6f7da3562f1503d5ef2a3d/src/libs/actions/IOU.ts#L6383-L6386 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 https://github.com/Expensify/App/blob/f3a8f736208166286e6f7da3562f1503d5ef2a3d/src/libs/PolicyUtils.ts#L370 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 https://github.com/Expensify/App/blob/f3a8f736208166286e6f7da3562f1503d5ef2a3d/src/libs/actions/IOU.ts#L6383-L6385

What alternative solutions did you explore? (Optional)

bernhardoj commented 1 month ago

Looks like this is the same as https://github.com/Expensify/App/issues/39171

OfstadC commented 1 month ago

Going to close since this is a duplicate