Skip to content

Reject blank-rendering display names via invisible-char-aware validation - #96468

Merged
mountiny merged 2 commits into
mainfrom
claude-blankDisplayNameValidation
Aug 3, 2026
Merged

mountiny merged 2 commits into
mainfrom
claude-blankDisplayNameValidation

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

The "Display Name" setting enforced a "required" check on the first name field with a raw length comparison (values.firstName.length === 0). This let a user save an all-invisible first name (e.g. U+200B Zero Width Space) that renders as a blank profile name.

The two characters called out in the report (U+200B, plain space) are already caught on main, because FormProvider runs StringUtils.removeInvisibleCharacters before validate() sees the value. The remaining gap is blank-rendering characters that are not in the \p{C} / \p{Z} Unicode groups and so slip through today — e.g. Braille Pattern Blank (U+2800, category So) and the Hangul fillers (U+115F, U+1160, U+FFA0, category Lo). Those save a blank-looking display name.

This PR closes that gap with two layers:

  1. Harden the field check — in DisplayNamePage.tsx validate(), replace the raw values.firstName.length === 0 with !isRequiredFulfilled(values.firstName) (from @libs/ValidationUtils). isRequiredFulfilled delegates to StringUtils.isEmptyString, the invisible-char-aware emptiness check. This keeps the page correct even if form trimming is ever disabled, and is the semantically correct helper.

  2. Close the class of bug — extend CONST.REGEX.OTHER_INVISIBLE_CHARACTERS to also cover U+115F, U+1160, U+FFA0, and U+2800. StringUtils.isEmptyString and removeInvisibleCharacters already consume this constant, so both validation and submission pick up the new code points automatically and every form benefits. The list is kept conservative — only code points that render blank/zero-advance — to avoid rejecting legitimate names. Verified none of these code points appear in the emoji assets.

Added unit tests to tests/unit/isEmptyString.ts and tests/unit/removeInvisibleCharacters.ts asserting the new blank glyphs are treated as empty.

Scope is App-only and self-scoped (a user's own display name); no backend change is needed. Consistent with the Low severity assessment on the issue.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/661474
PROPOSAL: https://github.com/Expensify/Expensify/issues/661474#issuecomment-5021069036

Tests

Setup: you need a few blank-rendering characters on the clipboard. Copy them from between the pipes below (each pipe pair contains exactly one character):

  • Braille Pattern Blank U+2800: |⠀|
  • Hangul Filler U+3164: |ㅤ|
  • Halfwidth Hangul Filler U+FFA0: |ᅠ|
  • Zero Width Space U+200B: |​|

Blank first name is rejected

  1. Sign in and go to Settings (avatar) > Profile > Display name.
  2. Clear the "First name" field, paste the Braille Pattern Blank (U+2800) into it — the field will look empty but the Save button is enabled.
  3. Tap/click Save.
  4. Verify the form does not submit and the error "First name cannot be empty" appears under the "First name" field.
  5. Repeat steps 2–4 for each of the other characters (U+3164, U+FFA0, U+200B) and for a combination of several of them pasted together — verify the same error appears every time.
  6. Repeat steps 2–4 with a plain space and with the field simply left empty — verify the same error appears (no regression to the existing behavior).

Valid names still save
7. In "First name" type a normal name (e.g. Maria), leave "Last name" empty, and tap Save.
8. Verify the page closes with no error and the new display name shows on the Profile page, in the LHN header, and on your own messages in a chat.
9. Open Display name again, enter a first name that contains a blank glyph next to real letters (e.g. paste U+2800 then type Maria) and Save.
10. Verify it saves — only fully-blank input is rejected; a name with at least one visible character is still allowed.

Last name is unaffected
11. Set "First name" to a normal name and paste a blank glyph into "Last name", then Save.
12. Verify it saves without an error — "Last name" is optional and this PR does not change that.

Regressions in other invisible-character-aware flows
13. Open any chat, type a message that is only a Braille Pattern Blank (U+2800) and press Enter — verify nothing is sent (the empty-message behavior is unchanged).
14. Send a normal message containing emojis (e.g. Hello 👋🏽 👨‍👩‍👧‍👦) and verify the emojis still render correctly and are not stripped.

Unit tests
15. Run npm run test -- tests/unit/isEmptyString.ts tests/unit/removeInvisibleCharacters.ts and verify all tests pass.

  • Verify that no errors appear in the JS console

Offline tests

  1. Go to Settings > Profile > Display name.
  2. Turn off your network connection (or enable the offline mode toggle in dev).
  3. Paste a Braille Pattern Blank (U+2800) into "First name" and tap Save.
  4. Verify the "First name cannot be empty" error still appears immediately — validation is client-side and does not require a network request.
  5. Still offline, enter a valid first name and tap Save.
  6. Verify the page closes and the new display name shows optimistically (greyed out) in the Profile page and LHN.
  7. Restore the network connection and verify the display name persists after the request goes through, with no error and no revert.

QA Steps

Setup: copy the blank-rendering characters from between the pipes below (each pipe pair contains exactly one character):

  • Braille Pattern Blank U+2800: |⠀|
  • Hangul Filler U+3164: |ㅤ|
  • Halfwidth Hangul Filler U+FFA0: |ᅠ|
  • Zero Width Space U+200B: |​|
  1. Sign in to staging and go to Settings (avatar) > Profile > Display name.
  2. Clear the "First name" field and paste the Braille Pattern Blank (U+2800) — the field looks empty.
  3. Tap/click Save.
  4. Verify the form does not submit and the error "First name cannot be empty" appears under the "First name" field.
  5. Repeat steps 2–4 with U+3164, U+FFA0, U+200B, a plain space, and a combination of several of them — verify the same error appears each time.
  6. Enter a normal first name (e.g. Maria) and tap Save.
  7. Verify the page closes with no error and the display name updates on the Profile page, in the LHN header, and on your own messages in a chat.
  8. Open Display name again, paste U+2800 followed by a normal name (e.g. Maria) and Save — verify it saves, because the field contains visible characters.
  9. Set a valid first name, paste a blank glyph into "Last name" and Save — verify it saves with no error.
  10. Open any chat and try to send a message containing only U+2800 — verify nothing is sent.
  11. Send a message with emojis (e.g. Hello 👋🏽 👨‍👩‍👧‍👦) — verify emojis still render correctly and are not stripped.
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

MacOS: Chrome / Safari
Screen.Recording.2026-08-03.at.7.32.11.PM.mov

Co-authored-by: Maria D'Costa <MariaHCD@users.noreply.github.com>
@MelvinBot
MelvinBot requested a review from a team July 20, 2026 10:24
@codecov

codecov Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/CONST/index.ts 94.81% <ø> (ø)
src/pages/settings/Profile/DisplayNamePage.tsx 0.00% <0.00%> (ø)
... and 9 files with indirect coverage changes

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The only failing check is PR Author Checklist / checklist, and there is nothing for me to fix in code — every real check passes.

Why it's failing: the authorChecklist.ts step reports You completed 0 out of 38 checklist items. This check only turns green when a human ticks the boxes in the PR Author Checklist section of the description (and fills in the Tests / QA Steps, which are currently // TODO placeholders). I intentionally don't tick those on a person's behalf.

Everything else is green: typecheck, Bun tests, all test (job N), ESLint, Oxfmt, Storybook, spellcheck, knip, unused-styles, all build (...) variants, and the perf tests all pass.

Next step (human co-author): complete the PR Author Checklist boxes and replace the // TODO in the Tests and QA Steps sections with the real steps (e.g. Settings → Profile → Display name; paste a blank glyph like U+2800/U+200B into First name, Save, verify the "First name cannot be empty" error blocks the save, and that a normal name still saves). The checklist check will then pass.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The only failing check is PR Author Checklist / checklist, and it's not a code problem — there's nothing for me to fix or push.

It fails because the checklist boxes in the PR description aren't ticked:

You completed 0 out of 38 checklist items with 38 unfinished items… PR Author Checklist is not completely filled out.

This one requires the human author to review and check each box — it can't (and shouldn't) be auto-filled. Once you tick the boxes in the PR description, the check re-runs and goes green.

Everything else is passing: Bun tests, ESLint, Oxfmt, typecheck, all test (job N), Storybook, spellcheck, React Compiler, builds, etc. The baseline-perf-tests / branch-perf-tests were still running when I checked, but this PR only changes validation logic (a regex constant + swapping a length check for isRequiredFulfilled) and doesn't touch any rendered component, so it has no plausible impact on those.

Action needed: complete the PR Author Checklist in the description to clear the failing check.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The only failing check on this PR is PR Author Checklist / checklist — every other check passes (validate-perf-tests is still pending, not failed).

This one isn't a code failure I can push a fix for: the PR Author Checklist workflow fails until the author checklist boxes in the PR description are ticked, which is a human step. Since I opened this PR as a bot, the checkboxes need to be completed by a person (e.g. the assignee) verifying the manual test steps and platform testing before it can pass.

No code change is warranted here — there's nothing broken in the branch. To clear the check, complete the PR Author Checklist items in the description.

@MariaHCD
MariaHCD marked this pull request as ready for review August 3, 2026 15:35
@MariaHCD
MariaHCD requested a review from a team as a code owner August 3, 2026 15:35
@melvin-bot
melvin-bot Bot requested review from flaviadefaria and gijoe0295 August 3, 2026 15:35
@melvin-bot

melvin-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

@gijoe0295 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot requested review from a team and mananjadhav and removed request for a team August 3, 2026 15:35
@melvin-bot

melvin-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

@mananjadhav Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@MelvinBot

Copy link
Copy Markdown
Contributor Author

There are no failing checks to fix on this PR right now. The PR Author Checklist / checklist that was previously failing has since passed, and every other check is green. The only non-passing item is review, which is still in progress (a pending status check, not a failure).

Nothing to push — once the review check finishes, the PR should be all green.

@mountiny mountiny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari

@mountiny
mountiny merged commit dd7ebe7 into main Aug 3, 2026
46 of 49 checks passed
@mountiny
mountiny deleted the claude-blankDisplayNameValidation branch August 3, 2026 16:10
@OSBotify

OSBotify commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify OSBotify mentioned this pull request Aug 3, 2026
77 tasks done
@OSBotify

OSBotify commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.49-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 I reviewed the changes in this PR against Expensify's help site content under App/docs/articles, and no help site changes are required.

Why: This PR is an internal validation-hardening fix. It makes the Display name field reject inputs that are composed only of blank-rendering invisible characters (e.g. Braille Pattern Blank U+2800, Hangul fillers U+115F/U+1160/U+FFA0) by extending CONST.REGEX.OTHER_INVISIBLE_CHARACTERS and switching the field check to the invisible-char-aware isRequiredFulfilled helper. There's no new feature, no new setting, no changed UI label, and no change to the documented workflow.

The only help article that touches this area — How to update your display name — only explains how to edit your display name (Account > Profile > Display Name). It does not document display-name validation rules, so it remains accurate and doesn't need an update.

Since no docs changes are needed, I did not open a draft help site PR.

@OSBotify

OSBotify commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/arosiclair in version: 9.4.49-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants