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
Report - System message generated for merchant rules not seen for track expense submitted to WS #82879
Version Number: 9.3.22.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:#82438 Email or phone of affected tester (no customers):ibellicotest+2250@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Motorola MotoG60 / Android 12 (Hybrid app) - Windows 11 / Chrome App Component: Money Requests
Action Performed:
Prerequisite: Account has at least one workspace with rules enabled.
Prerequisite 2: Account has Self DM.
Open the staging.new.expensify.com website.
Navigate to "Workspace" > "Rules"
Scroll down to "Merchant Rules" and select "Add Merchant Rule"
Add any merchant in "For expenses with"
Add any category and description in "Apply these updates" and save the rule.
Navigate to Self DM.
Create a manual expense with merchant added in step 4.
Tap on "Submit to someone" and select workspace where rule were created.
Submit the expense without adding any category or description.
Navigate to workspace chat and open expense report.
Note that "Category" and "Description" fields were updated via created merchant rule.
Note that "Set the category to "XX" and description to "XX" via workspace rules" system message is not displayed.
Expected Result:
System generated message showing that category and description were updated via workspace rules, should be displayed when a track expense is submitted to workspace.
Actual Result:
System generated message showing that category and description were updated via workspace rules, is not displayed for track expenses submitted to workspace, despite fields being correclty updated. System message only appear when expense is created directly in workspace chat.
Please re-state the problem that we are trying to solve in this issue.
When a user submits a tracked expense to a workspace, the expense fields (category, description, etc.) are correctly updated by merchant rules, but the informational system message explaining which fields were changed and linking to the workspace rules page does not appear in the chat. This creates a confusing user experience where changes happen silently without explanation. The message does appear correctly when an expense is created directly in a workspace chat, indicating the feature works but is not invoked in the tracked expense flow.
What is the root cause of that problem?
The client-side rendering logic in src/libs/ModifiedExpenseMessage.ts requires two specific properties to be present in a MODIFIED_EXPENSE report action's originalMessage object before displaying the workspace rules attribution message:
policyRulesModifiedFields - an object mapping which expense fields were changed by rules
policyID - the workspace identifier used to construct a link to the rules page
When expenses are created directly within a workspace, the backend (Web-Expensify) correctly populates these fields in the MODIFIED_EXPENSE action. However, when a tracked expense is submitted to a workspace, the backend commands responsible for this flow do not populate policyRulesModifiedFields or policyID, even when merchant rules are successfully applied and modify the expense fields.
This is fundamentally a data contract violation. The client and backend have an implicit contract documented in the comment at lines 247-248:
* ModifiedExpense::getNewDotComment in Web-Expensify should match this.
* If we change this function be sure to update the backend as well.
The backend is responsible for populating originalMessage with rule modification metadata. The client correctly handles whatever the backend provides. The tracked expense submission flow simply bypasses the metadata population that occurs in the direct creation flow.
What changes do you think we should make in order to solve the problem?
This issue requires a backend-only fix in the Web-Expensify/Auth repository. No App repository changes are needed.
The following backend API commands need to be updated to populate policyRulesModifiedFields and policyID in the MODIFIED_EXPENSE report action when merchant rules modify expense fields:
CategorizeTrackedExpense - invoked from src/libs/actions/IOU/index.ts:6396
ShareTrackedExpense - invoked from src/libs/actions/IOU/index.ts:6490
AddTrackedExpenseToPolicy - invoked from src/libs/actions/IOU/index.ts:6048
For each command, when merchant rules are applied and modify expense fields:
Step 1: Determine which fields were modified by merchant rules (category, tag, comment/description, billable, reimbursable, tax)
Step 2: Create the MODIFIED_EXPENSE report action (this already happens)
Step 3: Populate originalMessage.policyRulesModifiedFields with the modified field names and their new values:
// Example structure matching the type at src/types/onyx/OriginalMessage.ts:838-849
policyRulesModifiedFields: {category?: string;// e.g., "Travel"
tag?: string;// e.g., "Tag1,Tag2"
comment?: string;// description field (backend key name)
merchant?: string;
billable?: boolean;
reimbursable?: boolean;
tax?: { field_id_TAX: { name: string; value: string; externalID: string}};}
Step 4: Populate originalMessage.policyID with the workspace policy ID
The client-side rendering code at src/libs/ModifiedExpenseMessage.ts:205-242 will then automatically display the properly formatted message using the translation strings defined in src/languages/en.ts:1506-1515.
What alternative solutions did you explore? (Optional)
Alternative 1: Client-side optimistic message generation
The client could attempt to predict which fields the backend will modify and create an optimistic MODIFIED_EXPENSE action with policyRulesModifiedFields. This was rejected because:
Merchant rule evaluation logic exists only on the backend - duplicating it client-side would create maintenance burden and potential for drift
The client creates MOVED_TRANSACTION actions optimistically (see src/libs/actions/IOU/index.ts:5951), not MODIFIED_EXPENSE actions
Would require reconciling optimistic state with backend response, adding complexity
Alternative 2: Modify the client check to not require policyID
We could modify the check at line 513 to only require policyRulesModifiedFields without policyID. This was rejected because:
The link to workspace rules (/workspaces/:policyID/rules) would be broken without the policy ID
Breaks the established pattern where both fields are always provided together
The unit tests in tests/unit/ModifiedExpenseMessageTest.ts:821-899 expect both fields
Alternative 3: Fetch policy rules and re-evaluate on the client after submission
After a tracked expense is submitted, the client could fetch the workspace's merchant rules and determine which fields should have been modified. This was rejected because:
Adds unnecessary network requests
Rule evaluation timing matters - the backend may apply rules based on state that has since changed
Violates the single source of truth principle (backend owns rule application)
Activity
melvin-bot commentedon Feb 19, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #82438
melvin-bot commentedon Feb 19, 2026
💬 A slack conversation has been started in #expensify-open-source
melvin-bot commentedon Feb 19, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @rojiphil (
External)melvin-bot commentedon Feb 19, 2026
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.melvin-bot commentedon Feb 19, 2026
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
6 remaining items
HiepPP commentedon Feb 19, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user submits a tracked expense to a workspace, the expense fields (category, description, etc.) are correctly updated by merchant rules, but the informational system message explaining which fields were changed and linking to the workspace rules page does not appear in the chat. This creates a confusing user experience where changes happen silently without explanation. The message does appear correctly when an expense is created directly in a workspace chat, indicating the feature works but is not invoked in the tracked expense flow.
What is the root cause of that problem?
The client-side rendering logic in
src/libs/ModifiedExpenseMessage.tsrequires two specific properties to be present in aMODIFIED_EXPENSEreport action'soriginalMessageobject before displaying the workspace rules attribution message:policyRulesModifiedFields- an object mapping which expense fields were changed by rulespolicyID- the workspace identifier used to construct a link to the rules pageThe check occurs at lines 513-522:
App/src/libs/ModifiedExpenseMessage.ts
Lines 513 to 522 in dc3e499
When expenses are created directly within a workspace, the backend (Web-Expensify) correctly populates these fields in the
MODIFIED_EXPENSEaction. However, when a tracked expense is submitted to a workspace, the backend commands responsible for this flow do not populatepolicyRulesModifiedFieldsorpolicyID, even when merchant rules are successfully applied and modify the expense fields.This is fundamentally a data contract violation. The client and backend have an implicit contract documented in the comment at lines 247-248:
App/src/libs/ModifiedExpenseMessage.ts
Lines 247 to 248 in dc3e499
The backend is responsible for populating
originalMessagewith rule modification metadata. The client correctly handles whatever the backend provides. The tracked expense submission flow simply bypasses the metadata population that occurs in the direct creation flow.What changes do you think we should make in order to solve the problem?
This issue requires a backend-only fix in the Web-Expensify/Auth repository. No App repository changes are needed.
The following backend API commands need to be updated to populate
policyRulesModifiedFieldsandpolicyIDin theMODIFIED_EXPENSEreport action when merchant rules modify expense fields:src/libs/actions/IOU/index.ts:6396src/libs/actions/IOU/index.ts:6490src/libs/actions/IOU/index.ts:6048For each command, when merchant rules are applied and modify expense fields:
Step 1: Determine which fields were modified by merchant rules (category, tag, comment/description, billable, reimbursable, tax)
Step 2: Create the
MODIFIED_EXPENSEreport action (this already happens)Step 3: Populate
originalMessage.policyRulesModifiedFieldswith the modified field names and their new values:Step 4: Populate
originalMessage.policyIDwith the workspace policy IDThe complete expected action structure:
{ "actionName": "MODIFIED_EXPENSE", "reportActionID": "generated-uuid", "originalMessage": { "policyID": "workspace-policy-id", "policyRulesModifiedFields": { "category": "Travel", "comment": "Description set by rule" } } }The client-side rendering code at
src/libs/ModifiedExpenseMessage.ts:205-242will then automatically display the properly formatted message using the translation strings defined insrc/languages/en.ts:1506-1515.What alternative solutions did you explore? (Optional)
Alternative 1: Client-side optimistic message generation
The client could attempt to predict which fields the backend will modify and create an optimistic
MODIFIED_EXPENSEaction withpolicyRulesModifiedFields. This was rejected because:MOVED_TRANSACTIONactions optimistically (seesrc/libs/actions/IOU/index.ts:5951), notMODIFIED_EXPENSEactionsAlternative 2: Modify the client check to not require policyID
We could modify the check at line 513 to only require
policyRulesModifiedFieldswithoutpolicyID. This was rejected because:/workspaces/:policyID/rules) would be broken without the policy IDtests/unit/ModifiedExpenseMessageTest.ts:821-899expect both fieldsAlternative 3: Fetch policy rules and re-evaluate on the client after submission
After a tracked expense is submitted, the client could fetch the workspace's merchant rules and determine which fields should have been modified. This was rejected because:
Files Modified
CategorizeTrackedExpense,ShareTrackedExpense,AddTrackedExpenseToPolicycommandsVerification Checklist
policyRulesModifiedFieldsandpolicyID(src/types/onyx/OriginalMessage.ts:828-849)CATEGORIZE_TRACKED_EXPENSEresponse includespolicyRulesModifiedFieldswhen rules matchEdge Cases for Backend Implementation
policyRulesModifiedFieldsobjectpolicyRulesModifiedFieldsproperty at allpolicyRulesModifiedFieldsto show the rule overrode user inputm-natarajan commentedon Feb 19, 2026
Reproduce, Chrome / v9.3.22-4
Screen.Recording.2026-02-19.at.18.33.57.mp4
luacmartins commentedon Feb 19, 2026
PR in review
luacmartins commentedon Mar 3, 2026
This is done