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
[$250] Report-Creating a text report field with name < > creates duplicate fields #74675
Version Number: V9.2.47-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack:#72375 Email or phone of affected tester (no customers):slottwo1alefish@gmail.com Issue reported by: Applause Internal Team Device used: Redminote 10s android 13 App Component: Workspace Settings
Action Performed:
Preconditions:
*Workspace created
*Report Fields feature enabled
1.Launch the app
2.Go to Workspace Settings → Reports → Report Fields
3.Tap Add Field
4.Enter Name: < >
5.Select Type: Text
6.Leave Initial Value empty
7.Tap Save
8.Observe the report field list
Expected Result:
Only one report field should be created with the name < >.
Actual Result:
Two report fields are created instead of one.
Both fields appear with the same name < >.
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.
Please re-state the problem that we are trying to solve in this issue.
When creating a text report field with the name < > (or any name containing angle brackets), two duplicate report fields are created instead of one. Both fields appear with the same name < > in the report fields list.
What is the root cause of that problem?
The root cause is a mismatch between frontend and backend fieldID generation logic when handling angle bracket characters (< and >).
The API Call
The frontend makes a call to the CreatePolicyReportField API endpoint:
The backend's CreatePolicyReportField API silently strips < and > characters from the fieldID, but the frontend is unaware of this sanitization, leading to the duplicate entries.
What changes do you think we should make in order to solve the problem?
We should sanitize angle brackets in the frontend's generateFieldID function to match the backend's behavior. This prevents the optimistic/server data mismatch.
/** * Generates a field ID based on the field name. */functiongenerateFieldID(name: string){return`field_id_${name.replace(CONST.REGEX.ANY_SPACE,'_').toUpperCase()}`;}
Proposed Implementation
/** * Generates a field ID based on the field name. */functiongenerateFieldID(name: string){// Remove angle brackets to match backend behavior which strips themconstsanitizedName=name.replace(/[<>]/g,'');return`field_id_${sanitizedName.replace(CONST.REGEX.ANY_SPACE,'_').toUpperCase()}`;}
Why This Solution Works
With this change, when a user creates a field named < >:
Result: Both create the same key expensify_field_id_ - no duplicates!
The optimistic data and server response now create identical keys, preventing duplicate entries in the fieldList.
What alternative solutions did you explore?
Alternative 1: Filter out duplicate fieldIDs in the UI (Rejected)
This approach filters out the field_id_ entry from display:
// In WorkspaceReportsPage.tsxreturnObject.fromEntries(Object.entries(policy.fieldList).filter(([_,value])=>value.fieldID!=='text_title'&&value.fieldID!=='field_id_'));
Why rejected:
Only hides the symptom, doesn't fix the root cause
Duplicate entry still exists in Onyx/database
Hardcodes a magic string 'field_id_' that may conflict with legitimate field names
Requires filtering in multiple UI locations
Doesn't prevent the data integrity issue
Alternative 2: Prevent angle brackets in validation (Rejected)
Add validation to reject names containing < or >:
if(/<|>/.test(name)){errors[INPUT_IDS.NAME]='Field names cannot contain < or > characters';}
Why rejected:
Too restrictive - users should be able to use these characters in field names
Only prevents the specific case, doesn't fix the underlying mismatch
The field name can contain angle brackets; it's only the fieldID generation that needs to handle them
Alternative 3: Fix backend to preserve angle brackets (Not feasible)
Change the backend to keep angle brackets in fieldIDs.
Why rejected:
May have security implications (HTML/XML injection concerns)
Backend behavior is likely intentional for sanitization
changed the title [-]Report-Creating a text report field with name < > creates duplicate fields[/-][+][$250] Report-Creating a text report field with name < > creates duplicate fields[/+]on Nov 11, 2025
@TaduJR's proposal sounds good to me! If we're sanitizing on the BE it makes sense to also do it on the FE and I agree that simply filtering/hiding the extra field is just a workaround. We may want to replace with some other char rather than just an empty string though, as otherwise you could end up with conflicting field_ids (multiple field_id_)?
this kind of seems like a backend bug, since the the fieldID is incorrect for the given name. If we simply sanitize it on the front end like we do currently on the backend, we might run into issues where entries with other characters that get stripped have the same fieldID of field_id_?
I'll take a look at what we're doing in the backend just to be sure. If that's not the case, then I agree that @TaduJR's proposal looks good.
OK yeah we're doing some sanitization on the backend that I think we might be able to adjust, making this internal for now. Sorry about that and thank you for the proposals!
Activity
melvin-bot commentedon Nov 10, 2025
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.daledah commentedon Nov 10, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
Two report fields are created instead of one.
Both fields appear with the same name < >.
What is the root cause of that problem?
When creating a new report field with the name
< >, the Back End is returning another report field with the idfield_id_What changes do you think we should make in order to solve the problem?
We should filter that redundant report field and also in
MoneyRequestViewReportFieldscomponentApp/src/pages/workspace/reports/WorkspaceReportsPage.tsx
Lines 74 to 80 in 3937a11
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.
TaduJR commentedon Nov 10, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
When creating a text report field with the name
< >(or any name containing angle brackets), two duplicate report fields are created instead of one. Both fields appear with the same name< >in the report fields list.What is the root cause of that problem?
The root cause is a mismatch between frontend and backend fieldID generation logic when handling angle bracket characters (
<and>).The API Call
The frontend makes a call to the
CreatePolicyReportFieldAPI endpoint:App/src/libs/API/types.ts
Line 361 in 5dc4f0c
App/src/libs/actions/Policy/ReportField.ts
Line 267 in 5dc4f0c
The Mismatch
When a user creates a report field with name
< >:fieldID: "field_id_<_>"(keeps angle brackets)CreatePolicyReportFieldAPI) strips angle brackets and returns:fieldID: "field_id_"(without angle brackets)This creates two different entries in the policy's
fieldList:expensify_field_id_<_>expensify_field_id_Both entries have the same
name: "< >"but differentfieldIDvalues, causing two fields to appear in the UI.Evidence from API Request/Response
Request to
CreatePolicyReportFieldAPI:Backend Response:
{ "policy": { "fieldList": [ { "type": "text", "fieldID": "field_id_", "name": "< >", "orderWeight": 2 } ] }, "onyxData": [ { "key": "policy_54EC812485A9EB3C", "onyxMethod": "merge", "value": { "fieldList": { "expensify_field_id_": { "fieldID": "field_id_", "name": "< >" } } } } ] }The backend's
CreatePolicyReportFieldAPI silently strips<and>characters from the fieldID, but the frontend is unaware of this sanitization, leading to the duplicate entries.What changes do you think we should make in order to solve the problem?
We should sanitize angle brackets in the frontend's
generateFieldIDfunction to match the backend's behavior. This prevents the optimistic/server data mismatch.Change Location
App/src/libs/WorkspaceReportFieldUtils.ts
Lines 65 to 70 in 5dc4f0c
Current Implementation
Proposed Implementation
Why This Solution Works
With this change, when a user creates a field named
< >:fieldID: "field_id_"(angle brackets removed)fieldID: "field_id_"(angle brackets removed)expensify_field_id_- no duplicates!The optimistic data and server response now create identical keys, preventing duplicate entries in the
fieldList.What alternative solutions did you explore?
Alternative 1: Filter out duplicate fieldIDs in the UI (Rejected)
This approach filters out the
field_id_entry from display:Why rejected:
'field_id_'that may conflict with legitimate field namesAlternative 2: Prevent angle brackets in validation (Rejected)
Add validation to reject names containing
<or>:Why rejected:
Alternative 3: Fix backend to preserve angle brackets (Not feasible)
Change the backend to keep angle brackets in fieldIDs.
Why rejected:
[-]Report-Creating a text report field with name < > creates duplicate fields[/-][+][$250] Report-Creating a text report field with name < > creates duplicate fields[/+]melvin-bot commentedon Nov 11, 2025
Job added to Upwork: https://www.upwork.com/jobs/~021988198188857296747
melvin-bot commentedon Nov 11, 2025
Triggered auto assignment to Contributor-plus team member for initial proposal review - @jjcoffee (
External)jjcoffee commentedon Nov 11, 2025
@TaduJR's proposal sounds good to me! If we're sanitizing on the BE it makes sense to also do it on the FE and I agree that simply filtering/hiding the extra field is just a workaround. We may want to replace with some other char rather than just an empty string though, as otherwise you could end up with conflicting field_ids (multiple
field_id_)?🎀👀🎀 C+ reviewed
melvin-bot commentedon Nov 11, 2025
Triggered auto assignment to @NikkiWines, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
NikkiWines commentedon Nov 11, 2025
this kind of seems like a backend bug, since the the
fieldIDis incorrect for the given name. If we simply sanitize it on the front end like we do currently on the backend, we might run into issues where entries with other characters that get stripped have the samefieldIDoffield_id_?I'll take a look at what we're doing in the backend just to be sure. If that's not the case, then I agree that @TaduJR's proposal looks good.
NikkiWines commentedon Nov 12, 2025
OK yeah we're doing some sanitization on the backend that I think we might be able to adjust, making this internal for now. Sorry about that and thank you for the proposals!
c3024 commentedon Nov 17, 2025
PR in review.
c3024 commentedon Nov 19, 2025
https://github.com/Expensify/Web-Expensify/pull/49448 deployed to production. This should be fixed.
@mitarachim , can you please retest?
mitarachim commentedon Nov 19, 2025
Hello @c3024 QA team unable to reproduce issue using latest build v9.2.60-1
Screenrecorder-2025-11-19-08-27-31-228.mp4
c3024 commentedon Nov 19, 2025
Thanks!