Skip to content

Rules-Merchant Rule created in offline is not greyed out & strikethrough when deleted #81138

Closed

Description

@mitarachim

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: V9.3.11-17
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #80853
Email or phone of affected tester (no customers): dreamnitethedragon+yydyd373@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Redminote 10S Android 13
App Component: Workspace Settings

Action Performed:

  1. Launch app
  2. Create a workspace
  3. Tap more features - Enable Rules
  4. Tap Rules
  5. Go offline
  6. Create a rule and save
  7. Note Rule is not greyed out
  8. Edit the rule and save
  9. Note Rule is not greyed out
  10. Open the rule and delete it
  11. Note Rule is not strikethrough

Expected Result:

Merchant Rule created in offline must be greyed out & strikethrough when deleted to be consistent with other features in app.

Actual Result:

Merchant Rule created in offline is not greyed out & strikethrough when deleted.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7063376_1769923852767.Screenrecorder-2026-02-01-10-53-43-651.mp4

View all open jobs on GitHub

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    DeployBlockerIndicates it should block deploying the API
    on Feb 2, 2026
  2. melvin-bot commented on Feb 2, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #80853

  3. melvin-bot commented on Feb 2, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  4. melvin-bot commented on Feb 2, 2026

    @melvin-bot

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

  5. github-actions commented on Feb 2, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. OSBotify commented on Feb 2, 2026

    @OSBotify
    Contributor

    🔍 Investigation Summary

    Classification: Frontend bug
    Causing PR: #80853 - "Remove dev lock from merchant rules" by @luacmartins (High confidence)
    Related Issues: #80855

    Recommendation: ROLL FORWARD

    PR #80853 enabled the merchant rules feature in staging by removing the dev lock. However, it did not implement the offline feedback functionality required for proper offline behavior. The fix is straightforward and should be rolled forward rather than reverted.

    Labels: DeployBlocker label should remain, DeployBlockerCash label should remain (App changes needed)

    📋 Detailed Analysis

    Evidence

    The issue reports that merchant rules created/edited/deleted in offline mode do not show the grey-out and strikethrough visual indicators that are standard for offline operations in the app.

    PR #80853 changed only 2 lines in src/pages/workspace/rules/MerchantRulesSection.tsx:

    • Changed from checking isDevelopment to isProduction to enable the feature in staging

    Verification

    I examined the affected file and compared it with other rules sections:

    MerchantRulesSection.tsx (lines 127-146):

    • Directly renders MenuItemWithTopDescription components for each rule
    • Does NOT use the OfflineWithFeedback wrapper component
    • Does NOT pass any pendingAction prop

    IndividualExpenseRulesSection.tsx (lines 236-248) - Working correctly:

    <OfflineWithFeedback
        pendingAction={item.pendingAction}
        key={translate(item.descriptionTranslationKey)}
    >
        <MenuItemWithTopDescription
            shouldShowRightIcon
            title={item.title}
            description={translate(item.descriptionTranslationKey)}
            onPress={item.action}
            wrapperStyle={[styles.sectionMenuItemTopDescription]}
            numberOfLinesTitle={2}
        />
    </OfflineWithFeedback>

    ExpenseReportRulesSection.tsx also uses OfflineWithFeedback wrappers with pendingAction props.

    Root Cause

    The merchant rules feature was developed behind a dev lock and never had offline feedback implemented. When PR #80853 enabled it in staging, the missing offline functionality became visible.

    The backend actions (src/libs/actions/Policy/Rules.ts) properly set pendingAction on policy.pendingFields.rules for add/update/delete operations (lines 169, 271), but the UI component doesn't consume this data.

    Fix Required

    The fix needs to happen in MerchantRulesSection.tsx:

    1. Wrap each rule menu item with OfflineWithFeedback
    2. Pass the appropriate pendingAction (from policy?.pendingFields?.rules)
    3. Filter out null rules (deleted rules are set to null in the store)
    4. Handle the strikethrough styling for delete operations

    This is a simple UI fix that can be implemented quickly without reverting the feature.

  7. removed
    DeployBlockerIndicates it should block deploying the API
    on Feb 2, 2026
  8. marufsharifi commented on Feb 2, 2026

    @marufsharifi

    Proposal

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

    When a merchant rule is created, edited, or deleted while offline, the rule list does not show the usual offline feedback (greyed out for pending changes and strikethrough for pending delete). This is inconsistent with other areas of the app that show offline feedback for pending actions.

    What is the root cause of that problem?

    Merchant rules do not store a per-rule pendingAction on the rule itself. Instead, the rules logic only sets a policy-level pendingFields.rules flag, and the rules list does not wrap rows with OfflineWithFeedback. Because of this, the list has no per-item signal to apply offline styles or strikethrough when a rule is pending deletion.

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

    • Add a pendingAction field to the CodingRule type so each rule can carry its own offline status.
    • Update the optimistic rule writes:
      • For add/edit: set pendingAction on the rule while offline.
      • On success: clear pendingAction for that specific rule.
      • For delete: keep the rule in Onyx with pendingAction=DELETE instead of setting it to null immediately, so the UI can show strikethrough and dimmed styling.
      • On delete success: set the rule to null to remove it from the list.
    • Update the merchant rules list UI to wrap each row with OfflineWithFeedback, and disable navigation if a rule is pending delete to avoid editing a rule that is being removed.
    --- a/src/libs/actions/Policy/Rules.ts
    +++ b/src/libs/actions/Policy/Rules.ts
    @@ -123,6 +123,7 @@ function setPolicyCodingRule(policyID: string, form: MerchantRuleForm, policy: P
         const targetRuleID = ruleID ?? NumberUtils.rand64();
         const operator = form.matchType ?? CONST.SEARCH.SYNTAX_OPERATORS.CONTAINS;
         const created = existingRule?.created ?? new Date().toISOString();
    +    const pendingAction = isEditing ? CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE : CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD;
     
         // Rule for Onyx optimistic update (includes null values to remove cleared fields)
         const ruleForOnyx = {
    @@ -134,6 +135,7 @@ function setPolicyCodingRule(policyID: string, form: MerchantRuleForm, policy: P
             },
             ...ruleFieldsForOnyx,
             created,
    +        pendingAction,
         };
     
         // Rule for API (excludes null values)
    @@ -149,7 +151,6 @@ function setPolicyCodingRule(policyID: string, form: MerchantRuleForm, policy: P
         };
     
         const policyKey = `${ONYXKEYS.COLLECTION.POLICY}${policyID}` as const;
    -    const pendingAction = isEditing ? CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE : CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD;
     
         // On failure: for new rules, remove the optimistic rule; for edits, restore the original rule
         const failureRuleValue = isEditing ? existingRule : null;
    @@ -176,6 +177,13 @@ function setPolicyCodingRule(policyID: string, form: MerchantRuleForm, policy: P
                     onyxMethod: Onyx.METHOD.MERGE,
                     key: policyKey,
                     value: {
    +                    rules: {
    +                        codingRules: {
    +                            [targetRuleID]: {
    +                                pendingAction: null,
    +                            },
    +                        },
    +                    },
                         pendingFields: {
                             rules: null,
                         },
    @@ -264,7 +272,7 @@ function deletePolicyCodingRule(policy: Policy, ruleID: string) {
                     value: {
                         rules: {
                             codingRules: {
    -                            [ruleID]: null,
    +                            [ruleID]: existingRule ? {...existingRule, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE} : null,
                             },
                         },
                         pendingFields: {
    @@ -278,6 +286,11 @@ function deletePolicyCodingRule(policy: Policy, ruleID: string) {
                     onyxMethod: Onyx.METHOD.MERGE,
                     key: policyKey,
                     value: {
    +                    rules: {
    +                        codingRules: {
    +                            [ruleID]: null,
    +                        },
    +                    },
                         pendingFields: {
                             rules: null,
                         },
    --- a/src/pages/workspace/rules/MerchantRulesSection.tsx
    +++ b/src/pages/workspace/rules/MerchantRulesSection.tsx
    @@ -3,6 +3,7 @@ import {View} from 'react-native';
     import Badge from '@components/Badge';
     import MenuItem from '@components/MenuItem';
     import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
    +import OfflineWithFeedback from '@components/OfflineWithFeedback';
     import Section from '@components/Section';
     import Text from '@components/Text';
     import useEnvironment from '@hooks/useEnvironment';
    @@ -129,18 +130,22 @@ function MerchantRulesSection({policyID}: MerchantRulesSectionProps) {
                             const isExactMatch = rule.filters?.operator === CONST.SEARCH.SYNTAX_OPERATORS.EQUAL_TO;
                             const matchDescription = translate('workspace.rules.merchantRules.ruleSummaryTitle', merchantName, isExactMatch);
                             const ruleDescription = getRuleDescription(rule, translate, fieldLabels);
    +                        const isPendingDelete = rule.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
     
                             return (
                                 <View key={rule.ruleID}>
    -                                <MenuItemWithTopDescription
    -                                    description={matchDescription}
    -                                    title={ruleDescription}
    -                                    wrapperStyle={[styles.sectionMenuItemTopDescription]}
    -                                    descriptionTextStyle={[styles.textStrong, styles.themeTextColor, styles.fontSizeNormal]}
    -                                    titleStyle={[styles.textLabelSupporting, styles.fontSizeLabel]}
    -                                    shouldShowRightIcon
    -                                    onPress={() => Navigation.navigate(ROUTES.RULES_MERCHANT_EDIT.getRoute(policyID, rule.ruleID))}
    -                                />
    +                                <OfflineWithFeedback pendingAction={rule.pendingAction}>
    +                                    <MenuItemWithTopDescription
    +                                        description={matchDescription}
    +                                        title={ruleDescription}
    +                                        wrapperStyle={[styles.sectionMenuItemTopDescription]}
    +                                        descriptionTextStyle={[styles.textStrong, styles.themeTextColor, styles.fontSizeNormal]}
    +                                        titleStyle={[styles.textLabelSupporting, styles.fontSizeLabel]}
    +                                        shouldShowRightIcon
    +                                        disabled={isPendingDelete}
    +                                        onPress={isPendingDelete ? undefined : () => Navigation.navigate(ROUTES.RULES_MERCHANT_EDIT.getRoute(policyID, rule.ruleID))}
    +                                    />
    +                                </OfflineWithFeedback>
                                 </View>
                             );
                         })}
    --- a/src/types/onyx/Policy.ts
    +++ b/src/types/onyx/Policy.ts
    @@ -1744,6 +1744,9 @@ type CodingRule = {
     
         /** When this rule was created */
         created?: string;
    +
    +    /** The pending action for offline updates */
    +    pendingAction?: OnyxCommon.PendingAction;
     };

    What alternative solutions did you explore? (Optional)

  9. luacmartins commented on Feb 2, 2026

    @luacmartins
    Contributor

    NAB feature is not available in prod. The project team will address this.

  10. added and removed
    DeployBlockerCashThis issue or pull request should block deployment
    on Feb 2, 2026
  11. luacmartins commented on Feb 2, 2026

    @luacmartins
    Contributor

    I'm working on this

  12. added
    ReviewingHas a PR in review
    and removed on Feb 2, 2026
  13. luacmartins commented on Feb 2, 2026

    @luacmartins
    Contributor

    PR in review

  14. JS00001 commented on Feb 3, 2026

    @JS00001
    Contributor

    This is merged, closing it out

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.EngineeringReviewingHas a PR in reviewWeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions