Skip to content

[Due for payment 2026-08-25] [$250] Expense Rules Without Reimbursable/Billable in Classic Default to “No” in New Expensify #89142

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: 9.3.64-13
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from BrowserStack:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @twisterdotcom
Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

  1. Create an Expense Rule in Expensify Classic
  2. Enter Merchant Test
  3. Amend the Category option ONLY
  4. Save the Expense Rule
  5. Open New Expensify
  6. View the Expense Rule
  7. See "Reimbursable" appears to be empty
  8. Click/Tap into it
  9. See it is set to No

Expected Result:

Reimbursable and Billable options should not be set at all

Actual Result:

Both are set in ND and both affect matching expenses accordingly.

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

Screenshots/Videos

Recording.2766.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022049258164943265749
  • Upwork Job ID: 2049258164943265749
  • Last Price Increase: 2026-07-21

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Apr 28, 2026
  2. MelvinBot commented on Apr 28, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The frontend display logic correctly distinguishes between "not set" (undefined) and "explicitly set to No" ('false'). However, the backend serializes reimbursable and billable as the string 'false' for rules created in Classic even when the user never touched those fields — instead of omitting them entirely.

    In RulePageBase.tsx:207, the display check is form?.reimbursable ? translate(...) : ''. Since the string 'false' is truthy in JavaScript, any rule where the backend sends reimbursable: 'false' (instead of omitting it) will display "No" rather than being empty.

    The same issue exists in ExpenseRuleUtils.ts:40-54 where if (rule.billable) and if (rule.reimbursable) are truthy for the string 'false', causing the rule summary to incorrectly include reimbursable/billable changes.

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

    The fix should be applied on the frontend since we can't easily change backend NVP serialization behavior for Classic-created rules. Both locations need to explicitly check for undefined instead of relying on truthiness:

    1. In RulePageBase.tsx:207-213: Change the display condition from form?.reimbursable ? ... to form?.reimbursable !== undefined ? ... (same for billable).

    2. In ExpenseRuleUtils.ts:40,53: Change if (rule.billable) to if (rule.billable !== undefined) and if (rule.reimbursable) to if (rule.reimbursable !== undefined).

    This mirrors the pattern already used correctly in the workspace-level MerchantRulesSection.tsx:61-66 which checks rule.reimbursable !== undefined.

    What alternative solutions did you explore? (Optional)

    • Backend fix: Have the backend omit reimbursable/billable from the NVP when they were never set in Classic. This is the more "correct" fix but harder to change since it involves Classic NVP serialization behavior and could affect other consumers of that data.
    • Frontend normalization at load time: Convert 'false' to undefined when loading rules in ExpenseRulesPage.tsx. This was rejected because we can't distinguish between "user explicitly set No" and "backend defaulted to false" without backend changes — the !== undefined check is the safer, more consistent approach.

    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Apr 28, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Apr 28, 2026
  5. melvin-bot commented on Apr 28, 2026

    @melvin-bot

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

  6. changed the title [-]Expense Rules Without Reimbursable/Billable in Classic Default to “No” in New Expensify[/-] [+][$250] Expense Rules Without Reimbursable/Billable in Classic Default to “No” in New Expensify[/+] on Apr 28, 2026
  7. melvin-bot commented on Apr 28, 2026

    @melvin-bot
  8. aswin-s commented on Apr 28, 2026

    @aswin-s
    Contributor

    Proposal

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

    When a personal Expense Rule is created in Expensify Classic without reimbursable or billable configured, opening that rule in New Expensify preselects No for those fields instead of leaving them unset.

    What is the root cause of that problem?

    The edit flow for personal Expense Rules is hydrating EXPENSE_RULE_FORM with the persisted rule object as if the stored ExpenseRule shape already matched the draft form shape.

    In src/pages/settings/Rules/ExpenseRulesPage.tsx, navigateToEditRulePage() currently does:

    • spread expenseRule directly into setDraftRule()
    • then patches only comment and tax

    That is unsafe for this form. ExpenseRuleForm expects normalized draft values:

    • billable and reimbursable: 'true' | 'false' | undefined
    • comment: markdown
    • tax: tax external ID

    But persisted personal rules can arrive with Classic-style boolean values at runtime, especially false as the legacy “not configured” sentinel. After that raw boolean is written into EXPENSE_RULE_FORM, src/components/Rule/RuleBooleanBase.tsx treats any defined value in the string-backed flow as a real selection and maps boolean false to the No option when useStringValues is enabled.

    That is why the field page shows No, while the parent edit page still appears blank: src/pages/settings/Rules/RulePageBase.tsx uses a truthiness check for the title, so boolean false is treated as empty there.

    So the real bug is not in the selector UI itself. The real bug is that the personal rule edit flow is deserializing stored rule data into form state by spreading the persisted object instead of explicitly converting it to the form contract.

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

    1. Normalize persisted personal rules before writing them into EXPENSE_RULE_FORM.
      In src/pages/settings/Rules/ExpenseRulesPage.tsx, replace the raw ...expenseRule spread in navigateToEditRulePage() with an explicit mapping to the draft form shape, similar to how merchant rules are initialized in src/pages/workspace/rules/MerchantRules/MerchantRulePageBase.tsx.

    2. Convert the boolean fields with runtime-shape awareness:

      • preserve 'true' and 'false' if the rule already came from New Expensify
      • convert boolean true to 'true'
      • convert boolean false to undefined, because that is the Classic “unset” case causing this bug
    3. Keep the existing comment and tax normalization in the same mapping:

      • comment: HTML -> markdown
      • tax: field_id_TAX.externalID

    A clean version of the fix would be to move this conversion into a helper in src/libs/ExpenseRuleUtils.ts so the app has a dedicated “stored rule -> draft form” path, which is the inverse of extractRuleFromForm().

    What alternative solutions did you explore? (Optional)

    Changing src/components/Rule/RuleBooleanBase.tsx to special-case boolean false in the string-backed flow would only mask the symptom.

    That would still leave invalid runtime data inside EXPENSE_RULE_FORM, and if the user saved without touching those fields we could continue persisting the wrong shape back through the personal rule flow.

    The better fix is to correct the deserialization boundary when the stored rule is loaded into the personal rule draft form.

  9. github-actions commented on Apr 28, 2026

    @github-actions
    Contributor

    ⚠️ @aswin-s Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  10. emkhalid commented on Apr 29, 2026

    @emkhalid
    Contributor

    Proposal

    What is the root cause of that problem?

    Personal expense rules are stored in NVP_EXPENSE_RULES, but the stored data can contain legacy Classic boolean values for billable and reimbursable even though New Expensify expects string values ('true' | 'false' | undefined) for those fields.

    ExpenseRulesPage.tsx copies the persisted rule directly into EXPENSE_RULE_FORM with ...expenseRule.

    const commentMarkdown = expenseRule.comment ? Parser.htmlToMarkdown(expenseRule.comment) : undefined;
    setDraftRule({
    ...expenseRule,
    comment: commentMarkdown,
    tax: expenseRule.tax?.field_id_TAX ? expenseRule.tax.field_id_TAX.externalID : undefined,
    });

    That means a Classic rule where reimbursable/billable were never configured can put runtime false into the draft form. Then RuleBooleanBase.tsx treats any defined value as a real selection:

    let selectedItem = null;
    if (formValue !== undefined) {
    // Handle both string ('true'/'false') and boolean (true/false) values
    const isTruthy = useStringValues ? formValue === 'true' : formValue === true;
    const booleanValue = isTruthy ? CONST.SEARCH.BOOLEAN.YES : CONST.SEARCH.BOOLEAN.NO;
    selectedItem = booleanValues.find((value) => booleanValue === value) ?? null;

    Since false !== undefined, the boolean field page considers the value selected. With useStringValues, only 'true' maps to Yes, so runtime boolean false maps to No.

    The same legacy boolean values can also remain in NVP_EXPENSE_RULES, so matching expenses can treat those fields as explicitly set instead of unset.

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

    Normalize legacy personal expense rule booleans at the personal expense rules data boundary. This keeps the UI and save paths working with one schema:

    • true -> 'true'
    • false -> undefined
    • 'true' -> 'true'
    • 'false' -> 'false'

    This preserves explicit New Expensify No selections while removing Classic's legacy unset sentinel.

    In ExpenseRuleUtils.ts, add reusable normalization helpers and use them before formatting rule summaries.

    function formatExpenseRuleChanges(rule: ExpenseRule, translate: LocaleContextProps['translate']): string {
    const changes: string[] = [];
    const addChange = <K extends ChangeKey>(key: K, value: ValueForKey[K]) => {
    const translationKey = TRANSLATION_KEY_MAP[key][changes.length === 0 ? 'update' : 'partial'];
    changes.push(translate(translationKey as TranslationPaths, value as TranslationParameters<typeof translationKey>[0]));
    };
    if (rule.billable) {
    addChange('billable', rule.billable === 'true');
    }
    if (rule.category) {
    addChange('category', getDecodedCategoryName(rule.category));
    }
    if (rule.comment) {
    const commentMarkdown = Parser.htmlToMarkdown(rule.comment);
    addChange('comment', commentMarkdown);
    }
    if (rule.merchant) {
    addChange('merchant', rule.merchant);
    }
    if (rule.reimbursable) {
    addChange('reimbursable', rule.reimbursable === 'true');
    }
    if (rule.tag) {
    addChange('tag', getCommaSeparatedTagNameWithSanitizedColons(rule.tag));
    }
    if (rule.tax?.field_id_TAX?.value) {
    addChange('tax', rule.tax.field_id_TAX.value);
    }
    if (rule.report) {
    changes.push(translate('expenseRulesPage.changes.report', rule.report));
    }
    const formatted = changes.join(', ');
    return formatted.charAt(0).toUpperCase() + formatted.slice(1);

    +type LegacyExpenseRuleBoolean = ExpenseRule['billable'] | boolean;
    +
    +function normalizeExpenseRuleBoolean(value: LegacyExpenseRuleBoolean | undefined): ExpenseRule['billable'] | undefined {
    +    if (value === true) {
    +        return 'true';
    +    }
    +    if (value === false) {
    +        return undefined;
    +    }
    +    return value;
    +}
    +
    +function normalizeExpenseRule(rule: ExpenseRule): ExpenseRule {
    +    return {
    +        ...rule,
    +        billable: normalizeExpenseRuleBoolean(rule.billable as LegacyExpenseRuleBoolean | undefined),
    +        reimbursable: normalizeExpenseRuleBoolean(rule.reimbursable as LegacyExpenseRuleBoolean | undefined),
    +    };
    +}
    +
    +function normalizeExpenseRules(rules: ExpenseRule[]): ExpenseRule[] {
    +    return rules.map(normalizeExpenseRule);
    +}
    +
    +function hasLegacyExpenseRuleBooleanValues(rule: ExpenseRule): boolean {
    +    return (
    +        typeof (rule.billable as LegacyExpenseRuleBoolean | undefined) === 'boolean' ||
    +        typeof (rule.reimbursable as LegacyExpenseRuleBoolean | undefined) === 'boolean'
    +    );
    +}
    +
    +function hasLegacyExpenseRules(rules: ExpenseRule[]): boolean {
    +    return rules.some(hasLegacyExpenseRuleBooleanValues);
    +}
    +
     function formatExpenseRuleChanges(rule: ExpenseRule, translate: LocaleContextProps['translate']): string {
    +    const normalizedRule = normalizeExpenseRule(rule);
         const changes: string[] = [];
     
    -    if (rule.billable) {
    -        addChange('billable', rule.billable === 'true');
    +    if (normalizedRule.billable) {
    +        addChange('billable', normalizedRule.billable === 'true');
         }

    This makes rule-summary rendering ignore legacy boolean false and prevents it from showing as an explicit update.

    In ExpenseRulesPage.tsx, normalize the NVP values before using them for list rows and edit navigation, and trigger a cleanup write when legacy booleans are detected.

    import React, {useEffect, useState} from 'react';
    import {View} from 'react-native';
    import ActivityIndicator from '@components/ActivityIndicator';
    import Button from '@components/Button';
    import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu';
    import type {DropdownOption} from '@components/ButtonWithDropdownMenu/types';
    import ConfirmModal from '@components/ConfirmModal';
    import GenericEmptyStateComponent from '@components/EmptyStateComponent/GenericEmptyStateComponent';
    import HeaderWithBackButton from '@components/HeaderWithBackButton';
    import ScreenWrapper from '@components/ScreenWrapper';
    import ScrollView from '@components/ScrollView';
    import SearchBar from '@components/SearchBar';
    import TableListItem from '@components/SelectionList/ListItem/TableListItem';
    import type {ListItem} from '@components/SelectionList/types';
    import SelectionListWithModal from '@components/SelectionListWithModal';
    import CustomListHeader from '@components/SelectionListWithModal/CustomListHeader';
    import Text from '@components/Text';
    import useAutoTurnSelectionModeOffWhenHasNoActiveOption from '@hooks/useAutoTurnSelectionModeOffWhenHasNoActiveOption';
    import useDocumentTitle from '@hooks/useDocumentTitle';
    import useGenericEmptyStateIllustration from '@hooks/useGenericEmptyStateIllustration';
    import {useMemoizedLazyExpensifyIcons, useMemoizedLazyIllustrations} from '@hooks/useLazyAsset';
    import useLocalize from '@hooks/useLocalize';
    import useMobileSelectionMode from '@hooks/useMobileSelectionMode';
    import useNetwork from '@hooks/useNetwork';
    import useOnyx from '@hooks/useOnyx';
    import useResponsiveLayout from '@hooks/useResponsiveLayout';
    import useSearchResults from '@hooks/useSearchResults';
    import useThemeStyles from '@hooks/useThemeStyles';
    import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode';
    import {clearDraftRule, deleteExpenseRules, setDraftRule} from '@libs/actions/User';
    import {canUseTouchScreen} from '@libs/DeviceCapabilities';
    import {formatExpenseRuleChanges, getKeyForRule} from '@libs/ExpenseRuleUtils';
    import Navigation from '@libs/Navigation/Navigation';
    import Parser from '@libs/Parser';
    import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
    import tokenizedSearch from '@libs/tokenizedSearch';
    import CONST from '@src/CONST';
    import ONYXKEYS from '@src/ONYXKEYS';
    import ROUTES from '@src/ROUTES';
    import type {ExpenseRule} from '@src/types/onyx';
    import type DeepValueOf from '@src/types/utils/DeepValueOf';
    import getEmptyArray from '@src/types/utils/getEmptyArray';
    import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';
    const getKeyForList = (rule: ExpenseRule, index: number) => `${getKeyForRule(rule)}-${index}`;
    function ExpenseRulesPage() {
    const {translate, localeCompare} = useLocalize();
    const {isOffline} = useNetwork();
    const icons = useMemoizedLazyExpensifyIcons(['Pencil', 'Plus', 'Trashcan']);
    const illustrations = useMemoizedLazyIllustrations(['Flash']);
    const genericIllustration = useGenericEmptyStateIllustration();
    const isMobileSelectionModeEnabled = useMobileSelectionMode();
    const [expenseRules = getEmptyArray<ExpenseRule>(), expenseRulesResult] = useOnyx(ONYXKEYS.NVP_EXPENSE_RULES);
    const {shouldUseNarrowLayout} = useResponsiveLayout();
    useDocumentTitle(translate('expenseRulesPage.title'));
    const [selectedRules, setSelectedRules] = useState<string[]>([]);
    const [deleteConfirmModalVisible, setDeleteConfirmModalVisible] = useState(false);
    const styles = useThemeStyles();
    useEffect(() => {
    // Clear selection when rule is changed as hash is outdated
    // eslint-disable-next-line react-hooks/set-state-in-effect
    setSelectedRules([]);
    }, [expenseRules]);
    const hasRules = expenseRules.filter((rule) => isOffline || rule.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE).length > 0;
    const isLoading = !hasRules && isLoadingOnyxValue(expenseRulesResult);

    -import React, {useEffect, useState} from 'react';
    +import React, {useEffect, useMemo, useState} from 'react';
     
    -import {clearDraftRule, deleteExpenseRules, setDraftRule} from '@libs/actions/User';
    +import {clearDraftRule, deleteExpenseRules, normalizeStoredExpenseRules, setDraftRule} from '@libs/actions/User';
     
    -import {formatExpenseRuleChanges, getKeyForRule} from '@libs/ExpenseRuleUtils';
    +import {formatExpenseRuleChanges, getKeyForRule, normalizeExpenseRules} from '@libs/ExpenseRuleUtils';
     
    -    const [expenseRules = getEmptyArray<ExpenseRule>(), expenseRulesResult] = useOnyx(ONYXKEYS.NVP_EXPENSE_RULES);
    +    const [storedExpenseRules = getEmptyArray<ExpenseRule>(), expenseRulesResult] = useOnyx(ONYXKEYS.NVP_EXPENSE_RULES);
    +    const expenseRules = useMemo(() => normalizeExpenseRules(storedExpenseRules), [storedExpenseRules]);
     
    +    useEffect(() => {
    +        normalizeStoredExpenseRules(storedExpenseRules);
    +    }, [storedExpenseRules]);

    This fixes the edit flow because setDraftRule({...expenseRule}) now receives normalized values, so an unset Classic field stays unset.

    In User.ts, normalize rules before serializing save/delete writes and add a cleanup write for existing stored legacy values.

    App/src/libs/actions/User.ts

    Lines 1697 to 1819 in 79146fd

    function deleteExpenseRules(expenseRules: ExpenseRule[], selectedRuleKeys: string[], getKeyForRule: (rule: ExpenseRule) => string) {
    if (selectedRuleKeys.length === 0) {
    return;
    }
    // selectedRuleKeys are in format "${hash}-${index}" to distinguish duplicates
    const isRuleSelected = (rule: ExpenseRule, index: number) => {
    const keyForList = `${getKeyForRule(rule)}-${index}`;
    return selectedRuleKeys.includes(keyForList);
    };
    const optimisticRules = expenseRules.map((rule, index) => {
    if (isRuleSelected(rule, index)) {
    return {...rule, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE};
    }
    return rule;
    });
    const successRules = expenseRules.filter((rule, index) => !isRuleSelected(rule, index));
    const rulesForAPI = successRules.map(({pendingAction, errors, ...rule}) => rule);
    const failureRules = expenseRules.map((rule, index) => {
    if (isRuleSelected(rule, index)) {
    return {...rule, pendingAction: null, errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage')};
    }
    return rule;
    });
    const parameters: SetNameValuePairParams = {
    name: ONYXKEYS.NVP_EXPENSE_RULES,
    value: JSON.stringify(rulesForAPI),
    };
    const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.NVP_EXPENSE_RULES>> = [
    {
    onyxMethod: Onyx.METHOD.SET,
    key: ONYXKEYS.NVP_EXPENSE_RULES,
    value: optimisticRules,
    },
    ];
    const successData: Array<OnyxUpdate<typeof ONYXKEYS.NVP_EXPENSE_RULES>> = [
    {
    onyxMethod: Onyx.METHOD.SET,
    key: ONYXKEYS.NVP_EXPENSE_RULES,
    value: successRules,
    },
    ];
    const failureData: Array<OnyxUpdate<typeof ONYXKEYS.NVP_EXPENSE_RULES>> = [
    {
    onyxMethod: Onyx.METHOD.SET,
    key: ONYXKEYS.NVP_EXPENSE_RULES,
    value: failureRules,
    },
    ];
    API.write(WRITE_COMMANDS.SET_NAME_VALUE_PAIR, parameters, {
    optimisticData,
    successData,
    failureData,
    });
    }
    function saveExpenseRule(expenseRules: ExpenseRule[], newRule: ExpenseRule, existingRuleKey: string | undefined, getKeyForRule: (rule: ExpenseRule) => string) {
    const isEditing = !!existingRuleKey;
    const pendingAction = isEditing ? CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE : CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD;
    const ruleWithPendingAction: ExpenseRule = {
    ...newRule,
    pendingAction,
    };
    const ruleForSuccess: ExpenseRule = {
    ...newRule,
    pendingAction: null,
    errors: undefined,
    };
    let optimisticRules: ExpenseRule[];
    let successRules: ExpenseRule[];
    let failureRules: ExpenseRule[];
    if (isEditing) {
    let isUpdated = false;
    optimisticRules = expenseRules.map((rule) => {
    if (!isUpdated && getKeyForRule(rule) === existingRuleKey) {
    isUpdated = true;
    return ruleWithPendingAction;
    }
    return rule;
    });
    isUpdated = false;
    successRules = expenseRules.map((rule) => {
    if (!isUpdated && getKeyForRule(rule) === existingRuleKey) {
    isUpdated = true;
    return ruleForSuccess;
    }
    return rule;
    });
    failureRules = expenseRules.map((rule) => {
    if (getKeyForRule(rule) === existingRuleKey) {
    return {...rule, pendingAction: null, errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage')};
    }
    return rule;
    });
    } else {
    optimisticRules = [...expenseRules, ruleWithPendingAction];
    successRules = [...expenseRules, ruleForSuccess];
    failureRules = expenseRules;
    }
    const rulesForAPI = successRules
    .filter((rule) => rule.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE)
    .map(({pendingAction: _pendingAction, errors: _errors, ...rule}) => rule);
    const parameters: SetNameValuePairParams = {
    name: ONYXKEYS.NVP_EXPENSE_RULES,
    value: JSON.stringify(rulesForAPI),
    };

    +import {hasLegacyExpenseRules, normalizeExpenseRule, normalizeExpenseRules} from '@libs/ExpenseRuleUtils';
     
     function deleteExpenseRules(expenseRules: ExpenseRule[], selectedRuleKeys: string[], getKeyForRule: (rule: ExpenseRule) => string) {
         if (selectedRuleKeys.length === 0) {
             return;
         }
     
    +    const normalizedExpenseRules = normalizeExpenseRules(expenseRules);
    +
    -    const optimisticRules = expenseRules.map((rule, index) => {
    +    const optimisticRules = normalizedExpenseRules.map((rule, index) => {
     
    -    const successRules = expenseRules.filter((rule, index) => !isRuleSelected(rule, index));
    +    const successRules = normalizedExpenseRules.filter((rule, index) => !isRuleSelected(rule, index));
     
    -    const failureRules = expenseRules.map((rule, index) => {
    +    const failureRules = normalizedExpenseRules.map((rule, index) => {
     }
     
    +function normalizeStoredExpenseRules(expenseRules: ExpenseRule[]) {
    +    if (!hasLegacyExpenseRules(expenseRules) || expenseRules.some((rule) => !!rule.pendingAction)) {
    +        return;
    +    }
    +
    +    const normalizedExpenseRules = normalizeExpenseRules(expenseRules);
    +    const rulesForAPI = normalizedExpenseRules.map(({pendingAction, errors, ...rule}) => rule);
    +
    +    API.write(WRITE_COMMANDS.SET_NAME_VALUE_PAIR, {
    +        name: ONYXKEYS.NVP_EXPENSE_RULES,
    +        value: JSON.stringify(rulesForAPI),
    +    }, {
    +        optimisticData: [{onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.NVP_EXPENSE_RULES, value: normalizedExpenseRules}],
    +        successData: [{onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.NVP_EXPENSE_RULES, value: normalizedExpenseRules}],
    +        failureData: [],
    +    });
    +}
    +
     function saveExpenseRule(expenseRules: ExpenseRule[], newRule: ExpenseRule, existingRuleKey: string | undefined, getKeyForRule: (rule: ExpenseRule) => string) {
         const isEditing = !!existingRuleKey;
         const pendingAction = isEditing ? CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE : CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD;
    +    const normalizedExpenseRules = normalizeExpenseRules(expenseRules);
    +    const normalizedNewRule = normalizeExpenseRule(newRule);
     
         const ruleWithPendingAction: ExpenseRule = {
    -        ...newRule,
    +        ...normalizedNewRule,
             pendingAction,
         };
     
         const ruleForSuccess: ExpenseRule = {
    -        ...newRule,
    +        ...normalizedNewRule,
             pendingAction: null,
             errors: undefined,
         };

    This prevents legacy boolean values from being re-saved when the user edits or deletes a rule, and it cleans existing Classic-created rules so matching expenses no longer see unset fields as explicit false updates.

    What alternative solutions did you explore? (Optional)

    I considered changing RuleBooleanBase.tsx to treat boolean false as unset when useStringValues is enabled. That only fixes the field page display and still leaves invalid legacy values in EXPENSE_RULE_FORM and NVP_EXPENSE_RULES.

    I also considered normalizing only inside navigateToEditRulePage() before setDraftRule(). That fixes opening/editing a rule, but it does not clean the stored NVP or prevent unrelated save/delete operations from preserving the legacy boolean shape.

    I considered changing truthiness checks in RulePageBase.tsx and formatExpenseRuleChanges(). That targets display symptoms, but the original problem is a mixed-schema stored value, so the fix should happen before the UI and write paths consume those rules.

  11. github-actions commented on Apr 29, 2026

    @github-actions
    Contributor

    ⚠️ @emkhalid Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  12. ryntgh commented on Apr 29, 2026

    @ryntgh
    Contributor

    Proposal

    What is the root cause of that problem?

    For OD created rules, when billable and reimbursable are not set, the form value is an empty string "" (not undefined)

    Image

    Meanwhile for ND created rules, we don't get empty string billable and reimbursable if they are not set

    Image

    Then in RuleBooleanBase, the check that determines the selected item only excludes undefined, so an empty string passes the check and gets evaluated as not-'true', which causes "No" to be selected by default

    if (formValue !== undefined) {
    // Handle both string ('true'/'false') and boolean (true/false) values
    const isTruthy = useStringValues ? formValue === 'true' : formValue === true;
    const booleanValue = isTruthy ? CONST.SEARCH.BOOLEAN.YES : CONST.SEARCH.BOOLEAN.NO;
    selectedItem = booleanValues.find((value) => booleanValue === value) ?? null;
    }

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

    We should only consider the value as "set" when it matches one of the valid expected states ('true'/'false' for string, or a boolean for boolean mode)

        const isFormValueSet = useStringValues ? formValue === 'true' || formValue === 'false' : typeof formValue === 'boolean';
        if (isFormValueSet) {
            // Handle both string ('true'/'false') and boolean (true/false) values
            const isTruthy = useStringValues ? formValue === 'true' : formValue === true;
            const booleanValue = isTruthy ? CONST.SEARCH.BOOLEAN.YES : CONST.SEARCH.BOOLEAN.NO;
            selectedItem = booleanValues.find((value) => booleanValue === value) ?? null;
        }

    if (formValue !== undefined) {
    // Handle both string ('true'/'false') and boolean (true/false) values
    const isTruthy = useStringValues ? formValue === 'true' : formValue === true;
    const booleanValue = isTruthy ? CONST.SEARCH.BOOLEAN.YES : CONST.SEARCH.BOOLEAN.NO;
    selectedItem = booleanValues.find((value) => booleanValue === value) ?? null;
    }

    What alternative solutions did you explore? (Optional)

    We could normalize the empty strings to undefined upstream in setDraftRule when loading a rule into the form, so the empty string never reaches RuleBooleanBase in the first place

            setDraftRule({
                ...expenseRule,
                comment: commentMarkdown,
                billable: expenseRule.billable || undefined,
                reimbursable: expenseRule.reimbursable || undefined,
                tax: expenseRule.tax?.field_id_TAX ? expenseRule.tax.field_id_TAX.externalID : undefined,
            });

    setDraftRule({
    ...expenseRule,
    comment: commentMarkdown,
    tax: expenseRule.tax?.field_id_TAX ? expenseRule.tax.field_id_TAX.externalID : undefined,
    });

    We can do the same for report and tag field if needed

  13. 75 remaining items

  14. parasharrajat commented on Aug 18, 2026

    @parasharrajat
    Member

    BugZero Checklist:

    Regression Test Proposal

    Test:

    1. Create an Expense Rule in Expensify Classic
    2. Enter Merchant Test
    3. Amend the Category option ONLY
    4. Save the Expense Rule
    5. Open New Expensify
    6. View the Expense Rule
    7. See "Reimbursable" appears to be empty
    8. Click/Tap into it
    9. See it is set to No

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-d463-a760-cd70-986be286fa74
  15. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Aug 18, 2026
  16. melvin-bot commented on Aug 24, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  17. melvin-bot commented on Aug 24, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  18. mallenexpensify commented on Aug 26, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @twilight2294 paid $250 via Upwork
    Contributor+: @parasharrajat due $250 via NewDot

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