Skip to content

[Due for payment 2025-07-28] [$250] For USD/Control workspace, eReceipts toggle is not auto enabled #64743

Closed

Description

@m-natarajan

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:
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: @m-natarajan
Slack conversation (hyperlinked to channel name): @Expensify QA

Action Performed:

Precondition: User creates a new account with USD as default currency and a control workspace

  1. Create a new account
  2. Select onboarding intent as Manage my team> 1 to 10 > QBD as accounting
  3. Navigate to workspace settings- more features
  4. Enable rules
  5. Navigate to Rules

Expected Result:

For Control USD workspace, eReceipts toggle is auto enabled

Actual Result:

For control USD workspace, eReceipts toggle is not auto enabled

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
Recording.1313.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021940006703460974779
  • Upwork Job ID: 1940006703460974779
  • Last Price Increase: 2025-07-15
  • Automatic offers:
    • brunovjk | Reviewer | 108072162
    • daledah | Contributor | 108072163
Issue OwnerCurrent Issue Owner: @dylanexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 23, 2025
  2. melvin-bot commented on Jun 23, 2025

    @melvin-bot

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

  3. ryntgh commented on Jun 23, 2025

    @ryntgh
    Contributor

    Proposal

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

    For USD/Control workspace, eReceipts toggle is not auto enabled

    What is the root cause of that problem?

    enablePolicyRules does not automatically enable eReceipts for Control USD workspaces when rules are enabled

    function enablePolicyRules(policyID: string, enabled: boolean, shouldGoBack = true) {

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

    Update the enablePolicyRules function to automatically enable eReceipts for Control USD workspaces when rules are enabled

        ...
        const shouldAutoEnableEReceipts = enabled && PolicyUtils.isControlPolicy(policy) && policy?.outputCurrency === CONST.CURRENCY.USD;
    
        const onyxData: OnyxData = {
            optimisticData: [
                {
                    onyxMethod: Onyx.METHOD.MERGE,
                    key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
                    value: {
                        areRulesEnabled: enabled,
                        preventSelfApproval: false,
                        ...(shouldAutoEnableEReceipts && {eReceipts: true}),
                        ...(!enabled ? DISABLED_MAX_EXPENSE_VALUES : {}),
                        pendingFields: {
                            areRulesEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
                            ...(shouldAutoEnableEReceipts && {eReceipts: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}),
                        },
                    },
                },
            ],
            successData: [
                {
                    onyxMethod: Onyx.METHOD.MERGE,
                    key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
                    value: {
                        pendingFields: {
                            areRulesEnabled: null,
                            ...(shouldAutoEnableEReceipts && {eReceipts: null}),
                        },
                    },
                },
            ],
            failureData: [
                {
                    onyxMethod: Onyx.METHOD.MERGE,
                    key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
                    value: {
                        areRulesEnabled: !enabled,
                        preventSelfApproval: policy?.preventSelfApproval,
                        ...(shouldAutoEnableEReceipts && {eReceipts: policy?.eReceipts}),
                        ...(!enabled
                            ? {
                                  maxExpenseAmountNoReceipt: policy?.maxExpenseAmountNoReceipt,
                                  maxExpenseAmount: policy?.maxExpenseAmount,
                                  maxExpenseAge: policy?.maxExpenseAge,
                              }
                            : {}),
                        pendingFields: {
                            areRulesEnabled: null,
                            ...(shouldAutoEnableEReceipts && {eReceipts: null}),
                        },
                    },
                },
            ],
        };
       ...

    function enablePolicyRules(policyID: string, enabled: boolean, shouldGoBack = true) {

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

    We can test enablePolicyRules to verify eReceipts auto-enabled when rules enabled on Control Workspace with USD currency

    What alternative solutions did you explore? (Optional)

  4. daledah commented on Jun 23, 2025

    @daledah
    Contributor

    Proposal

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

    For control USD workspace, eReceipts toggle is not auto enabled

    What is the root cause of that problem?

    We don't update the eRecepts to enable when the user enabled the Rules feature for Control USD workspace

    const parameters: SetPolicyRulesEnabledParams = {policyID, enabled};
    API.write(WRITE_COMMANDS.SET_POLICY_RULES_ENABLED, parameters, onyxData, {
    checkAndFixConflictingRequest: (persistedRequests) => resolveEnableFeatureConflicts(WRITE_COMMANDS.SET_POLICY_RULES_ENABLED, persistedRequests, parameters),
    });
    if (enabled && getIsNarrowLayout() && shouldGoBack) {
    goBackWhenEnableFeature(policyID);
    }
    }

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

    With control USD workspace we should enable the eReceipts

        if(enabled  && isControlPolicy(policy) && policy?.outputCurrency === CONST.CURRENCY.USD) {
            setWorkspaceEReceiptsEnabled(policyID, enabled);
        }
    

    const parameters: SetPolicyRulesEnabledParams = {policyID, enabled};
    API.write(WRITE_COMMANDS.SET_POLICY_RULES_ENABLED, parameters, onyxData, {
    checkAndFixConflictingRequest: (persistedRequests) => resolveEnableFeatureConflicts(WRITE_COMMANDS.SET_POLICY_RULES_ENABLED, persistedRequests, parameters),
    });
    if (enabled && getIsNarrowLayout() && shouldGoBack) {
    goBackWhenEnableFeature(policyID);
    }
    }

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

    We can add test for the enablePolicyRules function with control USD currency to verify that eReceipts auto-enabled

    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.

  5. dylanexpensify commented on Jun 25, 2025

    @dylanexpensify
    Contributor

    reviewing shortly!

  6. melvin-bot commented on Jun 30, 2025

    @melvin-bot

    @dylanexpensify Eep! 4 days overdue now. Issues have feelings too...

  7. melvin-bot commented on Jun 30, 2025

    @melvin-bot

    @dylanexpensify Huh... This is 4 days overdue. Who can take care of this?

  8. dylanexpensify commented on Jul 1, 2025

    @dylanexpensify
    Contributor

    Sounds like a bug! Confirming behavior real quick though in case I'm out of date on anything

  9. dylanexpensify commented on Jul 1, 2025

    @dylanexpensify
    Contributor

    Confirmed

  10. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 1, 2025
  11. changed the title [-]For USD/Control workspace, eReceipts toggle is not auto enabled[/-] [+][$250] For USD/Control workspace, eReceipts toggle is not auto enabled[/+] on Jul 1, 2025
  12. 54 remaining items

  13. melvin-bot commented on Jul 21, 2025

    @melvin-bot

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

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

  14. melvin-bot commented on Jul 21, 2025

    @melvin-bot

    @marcaaron @dylanexpensify @brunovjk / @daledah 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]

  15. dylanexpensify commented on Jul 28, 2025

    @dylanexpensify
    Contributor

    Payment summary:

    Contributor: @daledah $250 via Upwork
    Contributor+: @brunovjk $250 via Upwork

    Please apply/request!

  16. dylanexpensify commented on Jul 28, 2025

    @dylanexpensify
    Contributor

    @brunovjk please complete checklist, thank you!

  17. added a commit that references this issue on Jul 28, 2025
  18. brunovjk commented on Jul 28, 2025

    @brunovjk
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] 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: Comment

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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:

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal

    Test:

    1. Create a WS with USD as default currency
    2. Go to more features
    3. Enable rules, upgrade to control
    4. Go to Rules
    5. Verify that: eReceipt toggle is enabled.

    Do we agree 👍 or 👎

  19. melvin-bot commented on Jul 31, 2025

    @melvin-bot

    @dylanexpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions