Skip to content

[$250] Rules - "Auto-pay approved reports" feature does not work #62606

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

Open
8 of 16 tasks
lanitochka17 opened this issue May 22, 2025 · 13 comments
Open
8 of 16 tasks

[$250] Rules - "Auto-pay approved reports" feature does not work #62606

lanitochka17 opened this issue May 22, 2025 · 13 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Overdue

Comments

@lanitochka17
Copy link

lanitochka17 commented May 22, 2025

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.1.49-6
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: #60171
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to ND https://staging.new.expensify.com/
  2. Login with a gmail account
  3. Create a WS
  4. Go to the WS > More Features > Toggle on "Rules"
  5. Go to Rules > Toggle on "Auto-pay approved reports"
  6. Go to the WS chat
  7. Create an expense with amount 10, submit and approve it

Expected Result:

The expense should be auto-paid

Actual Result:

The expense is not auto-paid

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop
Platforms Tested: On which of our officially supported platforms was this issue tested:
  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Bug6839387_1747932693969.Screen_Recording_2025-05-22_at_1.46.05_PM.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021925688336725193077
  • Upwork Job ID: 1925688336725193077
  • Last Price Increase: 2025-05-22
Issue OwnerCurrent Issue Owner: @rushatgabhane
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels May 22, 2025
Copy link

melvin-bot bot commented May 22, 2025

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

@twisterdotcom
Copy link
Contributor

The feature auto-pays when you have a VBA, not just marks stuff as paid automatically right? So we should only allow that toggle when you have a VBA.

@gijoe0295
Copy link
Contributor

gijoe0295 commented May 22, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-05-23 10:21:44 UTC.

Proposal

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

The feature auto-pays when you have a VBA, not just marks stuff as paid automatically right? So we should only allow that toggle when you have a VBA.

What is the root cause of that problem?

We allow enabling that toggle when Make or track payment is enabled:

disabled: autoPayApprovedReportsUnavailable,
showLockIcon: autoPayApprovedReportsUnavailable,

const autoPayApprovedReportsUnavailable = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO;

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

Modify the autoPayApprovedReportsUnavailable so that the reimbursement is different from REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES.

Add another condition that the policy must have a VBBA and policy.areWorkflowsEnabled.

App/src/libs/PolicyUtils.ts

Lines 1218 to 1221 in 5935c96

function hasVBBA(policyID: string | undefined) {
const policy = getPolicy(policyID);
return !!policy?.achAccount?.bankAccountID;
}

so when the workspace has no bank account, the toggle would show like this:

Image

We need to adjust the subtitle text style to match with other rules:

Image

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

We can add an UI test for the rules in workspace rules page.

What alternative solutions did you explore? (Optional)

None

@twisterdotcom
Copy link
Contributor

So we should only allow that toggle when you have a VBA.

Yeah, I like this.

@twisterdotcom twisterdotcom added the External Added to denote the issue can be worked on by a contributor label May 22, 2025
Copy link

melvin-bot bot commented May 22, 2025

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

@melvin-bot melvin-bot bot changed the title Rules - "Auto-pay approved reports" feature does not work [$250] Rules - "Auto-pay approved reports" feature does not work May 22, 2025
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label May 22, 2025
Copy link

melvin-bot bot commented May 22, 2025

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

@ChavdaSachin
Copy link
Contributor

ChavdaSachin commented May 23, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-05-25 18:46:05 UTC.

Proposal

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

Rules - "Auto-pay approved reports" feature does not work

What is the root cause of that problem?

Missing condition here.

const autoPayApprovedReportsUnavailable = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO;

Currently we autoPayApprovedReportsUnavailable works as a flag to determine whether the toggle for auto approval should be locked or not. And this does not include any condition about VBBA.

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

Update autoPayApprovedReportsUnavailable flag.

const autoPayApprovedReportsUnavailable = policy?.reimbursementChoice !== CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES && policy?.areWorkflowsEnabled; 

Add additional flag hasPolicyVBBA here.

    const hasPolicyVBBA = hasVBBA(policyID);

function hasVBBA(policyID: string | undefined) {

Now use this new flag to conditionally disable the toggle option and pass a new subtitle.
currently there are only two subtitles none of which are suitable for the condition when reimbursement choice is true but no bank account is configured.

so add a new subtitle.(we could make add bank account clickable in case)

                autoPayApprovedReportsMissingVBBASubtitle: 'Please add a bank account to use this feature',

The exact line could be suggested by the design team.
And update the Option Item

        {
            title: translate('workspace.rules.expenseReportRules.autoPayApprovedReportsTitle'),
            subtitle: autoPayApprovedReportsUnavailable
                ? renderFallbackSubtitle({featureName: translate('common.payments').toLowerCase()})
                : !hasPolicyVBBA
                ? translate('workspace.rules.expenseReportRules.autoPayApprovedReportsMissingVBBASubtitle')
                : translate('workspace.rules.expenseReportRules.autoPayApprovedReportsSubtitle'),
            switchAccessibilityLabel: translate('workspace.rules.expenseReportRules.autoPayApprovedReportsTitle'),
            onToggle: (isEnabled: boolean) => {
                enablePolicyAutoReimbursementLimit(policyID, isEnabled);
            },
            disabled: autoPayApprovedReportsUnavailable || !hasPolicyVBBA,
            showLockIcon: autoPayApprovedReportsUnavailable || !hasPolicyVBBA,
            isActive: policy?.shouldShowAutoReimbursementLimitOption && !autoPayApprovedReportsUnavailable && hasPolicyVBBA,
            pendingAction: policy?.pendingFields?.shouldShowAutoReimbursementLimitOption,
            onToggle: (isEnabled: boolean) => {
                enableAutoApprovalOptions(policyID, isEnabled);
            },

{
title: translate('workspace.rules.expenseReportRules.autoApproveCompliantReportsTitle'),
subtitle: workflowApprovalsUnavailable
? renderFallbackSubtitle({featureName: translate('common.approvals').toLowerCase()})
: translate('workspace.rules.expenseReportRules.autoApproveCompliantReportsSubtitle'),
switchAccessibilityLabel: translate('workspace.rules.expenseReportRules.autoApproveCompliantReportsTitle'),
isActive: policy?.shouldShowAutoApprovalOptions && !workflowApprovalsUnavailable,
disabled: workflowApprovalsUnavailable,
showLockIcon: workflowApprovalsUnavailable,
pendingAction: policy?.pendingFields?.shouldShowAutoApprovalOptions,
onToggle: (isEnabled: boolean) => {
enableAutoApprovalOptions(policyID, isEnabled);
},

Note

This proposal emphasize on adding an additional subtitle translation to better guide the user about the requirement to enable the feature. Code style could be improved during PR.

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

NA

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.

@mountiny
Copy link
Contributor

@nyomanjyotisa @ahmedGaber93 @Julesssss this is related to your PR I believe #60171

@ahmedGaber93
Copy link
Contributor

this is related to your PR I believe #60171

Hmm! I think it is not related, Our PR just change some exist translation, but the issue here looks to have a broken flow of "Auto-pay approved reports"

@trjExpensify
Copy link
Contributor

Yeah, agreed. Just checked this one out. To confirm the expected behaviour:

  • The autoPay toggle should be locked, unless the workspace:
    • has Workflows enabled
    • has "Make or track Payments" enabled AND set to REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES (i.e "Direct reimbursement")
    • has a VBBA to facilitate reimbursement

For reference, below are the different copy states of the auto-pay toggle:

When not eligible to be enabled

Image

When eligible to be enabled

Image

When enabled

Image

@gijoe0295
Copy link
Contributor

Update my proposal to follow the above comment #62606 (comment)

@melvin-bot melvin-bot bot added the Overdue label May 25, 2025
@ChavdaSachin
Copy link
Contributor

@trjExpensify do you think we need to update the subtitle for the case where

  • has Workflows enabled ✅
  • has "Make or track Payments" enabled AND set to REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES (i.e "Direct reimbursement") ✅
  • has no VBBA to facilitate reimbursement ❌

like - "Please add a bank account to enable this feature"

@twisterdotcom
Copy link
Contributor

We already handle that don't we? We show the Connect bank account flow:

Image

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 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Overdue
Projects
None yet
Development

No branches or pull requests

8 participants