You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rules - Unable to save empty merchant field #84199
Version Number: 9.3.31-0 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:#83005 Email or phone of affected tester (no customers):sodijsojosjsdoj@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Mac 26.2 / Chrome App Component: Workspace Settings
Action Performed:
Precondition:
Rules are enabled.
Go to staging.new.expensify.com
Go to workspace settings > Rules.
Click Add merchant rule.
Click Merchant field under "Apply these updates".
Enter anything and save it.
Click the same Merchant field.
Clear the field and save it.
Expected Result:
User should be able to clear the field and save it in case they decide not to make any changes to merchant.
Actual Result:
User cannot clear Merchant field once it has been saved with value.
In order to clear it, user will need to close the RHP and restart the process.
👋 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:
Identify the pull request that introduced this issue and revert it.
Classification: Frontend bug Causing PR: #81205 - "fix Expense - Merchant can be made empty by using Expense as Merchant in expense rule" by @situchan (High confidence) Related PRs: #83005 - "Enable merchant rules v3" (exposed the issue by removing production gate)
Recommendation: ROLL FORWARD
The bug exists in validation logic added by PR #81205 (merged Feb 3), but was only exposed when PR #83005 removed the production gate for merchant rules. The issue is that the validation incorrectly prevents users from clearing the merchant field once a value has been saved.
Root Cause: The validation in src/components/Rule/TextBase.tsx calls isInvalidMerchantValue(trimmedValue) for non-required merchant fields. This function returns true for empty strings, which prevents users from clearing the field. The validation should only check for invalid values when the field is NOT empty.
Rolling forward with a fix is more appropriate than reverting because:
The fix is straightforward: skip isInvalidMerchantValue check when the field is empty and not required
Labels: No label changes needed. This is reproducible only on staging (new feature), and it is a frontend bug that requires an App PR to fix. DeployBlockerCash should remain.
Detailed Analysis
Evidence
Looking at the issue reproduction steps:
User fills the Merchant field under "Apply these updates" with a value
Saves it successfully
Tries to clear the field and save again
Gets an "Invalid merchant" error
The video shows this behavior clearly - the user cannot submit when the merchant field is cleared.
Verification
The affected file is /home/runner/_work/App/App/src/components/Rule/TextBase.tsx, specifically the validation function starting at line 48.
PR #81205 added this validation code (lines 65-69):
Notice it returns true when merchant is an empty string "".
Root Cause
The merchant field in AddMerchantPage is NOT marked as required (isRequired is not passed to RuleTextBase). However, the validation logic validates empty strings as "invalid" even for optional fields.
The correct behavior should be:
If the field is empty and NOT required: allow it (no error)
If the field is empty and IS required: show "field required" error
If the field has a value: validate that value
The current code validates empty strings as "invalid merchant" instead of allowing them for optional fields. The validation should be:
}elseif(fieldID===CONST.EXPENSE_RULES.FIELDS.RENAME_MERCHANT||fieldID===CONST.MERCHANT_RULES.FIELDS.MERCHANT){if(trimmedValue&&isInvalidMerchantValue(trimmedValue)){// Only check if not empty(errorsasRecord<string,string>)[fieldID]=translate("iou.error.invalidMerchant");}}
Please re-state the problem that we are trying to solve in this issue.
When editing a merchant rule under workspace Rules, the user enters a value in the Merchant field under "Apply these updates" and saves it. When they reopen the same field, clear the text, and try to save, the form refuses to submit. The user cannot clear a previously-saved Merchant value without discarding the entire rule.
What is the root cause of that problem?
The TextBase component's validate function unconditionally applies the isInvalidMerchantValue check to the MERCHANT_RULES.FIELDS.MERCHANT field (src/components/Rule/TextBase.tsx:65-68). The isInvalidMerchantValue function in src/libs/ValidationUtils.ts:775-776 treats an empty string as invalid (merchant === ''). This function was designed for expense transactions where an empty merchant is genuinely invalid, but it is reused here for an optional merchant rule field where clearing the value is a legitimate user action.
The Merchant field under "Apply these updates" is not required — AddMerchantPage does not pass isRequired to RuleTextBase (src/pages/workspace/rules/MerchantRules/AddMerchantPage.tsx:30-38), and the field is not marked required: true in the sections array of MerchantRulePageBase. However, because the isInvalidMerchantValue check runs regardless of the isRequired flag, an empty string always triggers a validation error ("Please enter a valid merchant"), and FormProvider blocks submission.
What changes do you think we should make in order to solve the problem?
In src/components/Rule/TextBase.tsx, the isInvalidMerchantValue check on lines 65-68 should only run when trimmedValue is non-empty. When the field is optional and the user clears it to an empty string, that should be treated as a valid "no value" state rather than an invalid merchant name.
The change is in the validate function: wrap the isInvalidMerchantValue(trimmedValue) call so it only fires when trimmedValue !== ''. This way, typing something like the internal partial-transaction placeholder would still be caught as invalid, but deliberately clearing the field would be allowed.
What alternative solutions did you explore? (Optional)
An alternative would be to modify isInvalidMerchantValue itself to not treat empty strings as invalid, but that function is shared across the codebase for expense transaction validation where empty merchant truly is invalid. Changing it globally could break other callsites. The fix is better scoped at the TextBase validation level where the optional vs. required distinction is known.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.
Activity
melvin-bot commentedon Mar 4, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #83005
melvin-bot commentedon Mar 4, 2026
💬 A slack conversation has been started in #expensify-open-source
melvin-bot commentedon Mar 4, 2026
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.github-actions commentedon Mar 4, 2026
👋 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:
OSBotify commentedon Mar 4, 2026
Investigation Summary
Classification: Frontend bug
Causing PR: #81205 - "fix Expense - Merchant can be made empty by using Expense as Merchant in expense rule" by @situchan (High confidence)
Related PRs: #83005 - "Enable merchant rules v3" (exposed the issue by removing production gate)
Recommendation: ROLL FORWARD
The bug exists in validation logic added by PR #81205 (merged Feb 3), but was only exposed when PR #83005 removed the production gate for merchant rules. The issue is that the validation incorrectly prevents users from clearing the merchant field once a value has been saved.
Root Cause: The validation in
src/components/Rule/TextBase.tsxcallsisInvalidMerchantValue(trimmedValue)for non-required merchant fields. This function returnstruefor empty strings, which prevents users from clearing the field. The validation should only check for invalid values when the field is NOT empty.Rolling forward with a fix is more appropriate than reverting because:
isInvalidMerchantValuecheck when the field is empty and not requiredLabels: No label changes needed. This is reproducible only on staging (new feature), and it is a frontend bug that requires an App PR to fix.
DeployBlockerCashshould remain.Detailed Analysis
Evidence
Looking at the issue reproduction steps:
The video shows this behavior clearly - the user cannot submit when the merchant field is cleared.
Verification
The affected file is
/home/runner/_work/App/App/src/components/Rule/TextBase.tsx, specifically the validation function starting at line 48.PR #81205 added this validation code (lines 65-69):
The
isInvalidMerchantValuefunction insrc/libs/ValidationUtils.ts(line 775) is defined as:Notice it returns
truewhen merchant is an empty string"".Root Cause
The merchant field in AddMerchantPage is NOT marked as required (
isRequiredis not passed to RuleTextBase). However, the validation logic validates empty strings as "invalid" even for optional fields.The correct behavior should be:
The current code validates empty strings as "invalid merchant" instead of allowing them for optional fields. The validation should be:
MelvinBot commentedon Mar 4, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When editing a merchant rule under workspace Rules, the user enters a value in the Merchant field under "Apply these updates" and saves it. When they reopen the same field, clear the text, and try to save, the form refuses to submit. The user cannot clear a previously-saved Merchant value without discarding the entire rule.
What is the root cause of that problem?
The
TextBasecomponent'svalidatefunction unconditionally applies theisInvalidMerchantValuecheck to theMERCHANT_RULES.FIELDS.MERCHANTfield (src/components/Rule/TextBase.tsx:65-68). TheisInvalidMerchantValuefunction insrc/libs/ValidationUtils.ts:775-776treats an empty string as invalid (merchant === ''). This function was designed for expense transactions where an empty merchant is genuinely invalid, but it is reused here for an optional merchant rule field where clearing the value is a legitimate user action.The Merchant field under "Apply these updates" is not required —
AddMerchantPagedoes not passisRequiredtoRuleTextBase(src/pages/workspace/rules/MerchantRules/AddMerchantPage.tsx:30-38), and the field is not markedrequired: truein the sections array ofMerchantRulePageBase. However, because theisInvalidMerchantValuecheck runs regardless of theisRequiredflag, an empty string always triggers a validation error ("Please enter a valid merchant"), andFormProviderblocks submission.What changes do you think we should make in order to solve the problem?
In
src/components/Rule/TextBase.tsx, theisInvalidMerchantValuecheck on lines 65-68 should only run whentrimmedValueis non-empty. When the field is optional and the user clears it to an empty string, that should be treated as a valid "no value" state rather than an invalid merchant name.The change is in the
validatefunction: wrap theisInvalidMerchantValue(trimmedValue)call so it only fires whentrimmedValue !== ''. This way, typing something like the internal partial-transaction placeholder would still be caught as invalid, but deliberately clearing the field would be allowed.What alternative solutions did you explore? (Optional)
An alternative would be to modify
isInvalidMerchantValueitself to not treat empty strings as invalid, but that function is shared across the codebase for expense transaction validation where empty merchant truly is invalid. Changing it globally could break other callsites. The fix is better scoped at theTextBasevalidation level where the optional vs. required distinction is known.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.situchan commentedon Mar 4, 2026
@MelvinBot implement this
vincdargento commentedon Mar 4, 2026
This issue is repro on all PRs in the current deployment checklist. Could you please double check if it's not introduced by #83005?
situchan commentedon Mar 4, 2026
The root cause exists in production. The fix should be quick
MelvinBot commentedon Mar 4, 2026
🤖 Draft PR created: #84209
Please mark it as "Ready for review" when it is ready for review.
luacmartins commentedon Mar 5, 2026
PR merged. Being CPEd
luacmartins commentedon Mar 5, 2026
PR CPed, this is fixed. Closing.