Skip to content

fix/78095: Comma split on locale languages#78246

Merged
dangrous merged 5 commits intoExpensify:mainfrom
btkcodedev:btkcodedev/78095CommaSpanish
Jan 8, 2026
Merged

fix/78095: Comma split on locale languages#78246
dangrous merged 5 commits intoExpensify:mainfrom
btkcodedev:btkcodedev/78095CommaSpanish

Conversation

@btkcodedev
Copy link
Contributor

Explanation of Change

Updating the input validation regex fixes the Split Expense issue in Spanish, allowing users to enter commas, add digits after a comma, and use the Delete key in the Percentage tab.

Fixed Issues

$ #78095
PROPOSAL: #78095 (comment)

Tests

Precondition:
App language is Spanish.

Bug 1: A comma cannot be entered in the percentage input field
Go to staging.new.expensify.com
Go to workspace chat.
Create an expense of the amount 30.00
Open expense report.
Click More > Split > Percent.
Click on any input field.
Enter a comma.
Verify that a comma can be entered now in the percentage input field

Bug 2: Numbers cannot be added after entering a comma
Continue from Bug 1.
Enter a number after the comma.
Verify that numbers can be entered after a comma.

Bug 3: The delete key does nothing when pressed
Continue from Bug 1.
In the Percent tab, press the Delete key.
Verify that the Delete key removes numbers from the field.

  • Verify that no errors appear in the JS console

Offline tests

Same as above

QA Steps

Bug 1: A comma cannot be entered in the percentage input field
Go to staging.new.expensify.com
Go to workspace chat.
Create an expense of the amount 30.00
Open expense report.
Click More > Split > Percent.
Click on any input field.
Enter a comma.
Verify that a comma can be entered now in the percentage input field

Bug 2: Numbers cannot be added after entering a comma
Continue from Bug 1.
Enter a number after the comma.
Verify that numbers can be entered after a comma.

Bug 3: The delete key does nothing when pressed
Continue from Bug 1.
In the Percent tab, press the Delete key.
Verify that the Delete key removes numbers from the field.

  • 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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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

Android: HybridApp
Screen_Recording_20251222_004045_New.Expensify.Dev.2.mp4
Android: mWeb Chrome
Screen_Recording_20251222_002247_Brave.mp4
iOS: HybridApp
Screen.Recording.2025-12-22.at.1.13.18.AM.mov
iOS: mWeb Chrome
Screen.Recording.2025-12-22.at.1.09.24.AM.mov
MacOS: Chrome / Safari
Screen.Recording.2025-12-19.at.9.27.04.PM.mov

@btkcodedev btkcodedev requested review from a team as code owners December 21, 2025 19:51
@melvin-bot melvin-bot bot requested review from heyjennahay and suneox and removed request for a team December 21, 2025 19:51
@melvin-bot
Copy link

melvin-bot bot commented Dec 21, 2025

@suneox 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 removed the request for review from a team December 21, 2025 19:51
@github-actions
Copy link
Contributor

github-actions bot commented Dec 21, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@btkcodedev
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

CLABotify added a commit to Expensify/CLA that referenced this pull request Dec 21, 2025
@btkcodedev
Copy link
Contributor Author

Test case results:
image

@suneox
Copy link
Contributor

suneox commented Dec 24, 2025

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 there are no new alerts related to the canBeMissing param for useOnyx
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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
CleanShot.2025-12-25.at.00.57.31__2.mp4
Android: mWeb Chrome
CleanShot.2025-12-25.at.01.00.05__2.mp4
iOS: HybridApp
CleanShot.2025-12-25.at.00.53.23__2.mp4
iOS: mWeb Safari
CleanShot.2025-12-25.at.00.51.07__2.mp4
MacOS: Chrome / Safari
CleanShot.2025-12-25.at.00.55.18__2.mp4

const strippedAmount = stripCommaFromAmount(newAmountWithoutSpaces);
onInputChange?.(strippedAmount);
// Convert comma to period for internal representation (commas are used as decimal separators in some locales like Spanish)
const normalizedAmount = newAmountWithoutSpaces.replace(',', '.');
Copy link
Contributor

Choose a reason for hiding this comment

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

We can using existing func

Suggested change
const normalizedAmount = newAmountWithoutSpaces.replace(',', '.');
const normalizedAmount = replaceCommasWithPeriod(newAmountWithoutSpaces);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done ✅

@btkcodedev
Copy link
Contributor Author

Test cases passed on latest commit without any issues
image

@btkcodedev btkcodedev requested a review from suneox December 26, 2025 05:35
@melvin-bot melvin-bot bot requested a review from dangrous December 26, 2025 05:36
Copy link
Contributor

@dangrous dangrous left a comment

Choose a reason for hiding this comment

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

Thank you for putting this through! Test cases brought up one question that we might need to adjust for.

Comment on lines +100 to +101
expect(validatePercentage('1,234.56', true, true)).toBe(false);
expect(validatePercentage('1.234,56', true, true)).toBe(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

These are the only test cases I'm unsure about - should these be accepted (assuming allowExceedingHundred)? Both would be valid percentages, since the first punctuation is being used as a hundreds separator instead of a decimal. What would the first one 1,234.56 return BEFORE we made the changes in this branch?

I realize we may need to do some combo of replaceCommasWithPeriod and stripCommasFromAmount - maybe we swap all periods with commas or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clarifications:

  1. Before this branch, the regex only allowed one period not comma(which is the whole issue), so 1,234.56 would have been obviously rejected.
    Currently new regex - [.,]? optionally ONE comma or period followed by \d? optionally ONE more digit

  2. Regarding the concern about users entering commas as thousands separators: the input allows only a single decimal digit. This greatly limits the possibility of mixed notation or user confusion.

  3. a) Percentages 0-100 should never need thousands separators as in default
    b) IF allowExceedingHundred is passed, this is regex: /^\d*[.,]?\d?$/u - very permissive, allows any number with optional one decimal

The validation correctly supports either a comma or a period as the decimal separator, but not thousands separators or mixed notation, which is appropriate for percentages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CC @dangrous 🙇

Copy link
Contributor

Choose a reason for hiding this comment

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

hrm okay - @heyjennahay from a product perspective, what do you think here? Is it okay to disallow someone putting 1,234.56 into the percentage (while allowing 1234.56)? I think it's pretty much an edge case, but since we're in there changing the logic, figured I'd check. Seems like it would make it a little more complicated

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the slow reply. I think this is fine. As you say, it is an edge case and not really worth putting a "complete" solution which handles all cases.

@codecov
Copy link

codecov bot commented Dec 26, 2025

Codecov Report

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

Files with missing lines Coverage Δ
src/components/PercentageForm.tsx 0.00% <ø> (ø)
src/libs/MoneyRequestUtils.ts 52.63% <100.00%> (ø)
... and 19 files with indirect coverage changes

@suneox
Copy link
Contributor

suneox commented Dec 27, 2025

@btkcodedev Oops — the pipeline just finished running after the PR was approved, and we still have issues with commit signing and the prettier check that need to be resolved.

  • After configuring signed commits, you can squash all commits, run prettier-changed, and then re-push.

@btkcodedev btkcodedev force-pushed the btkcodedev/78095CommaSpanish branch from f5fffd6 to 4ee02d3 Compare December 27, 2025 04:17
@btkcodedev
Copy link
Contributor Author

Thanks @suneox
Done, Please re-run validation checks 🙇

@btkcodedev btkcodedev requested a review from dangrous December 27, 2025 07:46
Copy link
Contributor

@dangrous dangrous left a comment

Choose a reason for hiding this comment

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

LGTM pending decision here

Copy link
Contributor

@dangrous dangrous left a comment

Choose a reason for hiding this comment

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

LGTM pending decision here

@btkcodedev
Copy link
Contributor Author

btkcodedev commented Dec 31, 2025

LGTM pending decision here

CC: @heyjennahay

@btkcodedev
Copy link
Contributor Author

@heyjennahay Bump on previous comment

Copy link
Contributor

@heyjennahay heyjennahay left a comment

Choose a reason for hiding this comment

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

Product change LGTM

@dangrous
Copy link
Contributor

dangrous commented Jan 8, 2026

This is good to go but can you merge main one more time just to make sure there isn't anything unexpected @btkcodedev ?

Thanks!

@btkcodedev
Copy link
Contributor Author

Done @dangrous

@dangrous dangrous merged commit f262254 into Expensify:main Jan 8, 2026
29 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Jan 8, 2026

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

@OSBotify
Copy link
Contributor

OSBotify commented Jan 9, 2026

🚀 Deployed to staging by https://github.com/dangrous in version: 9.2.97-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/dangrous in version: 9.2.99-0 🚀

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

@suneox
Copy link
Contributor

suneox commented Jan 12, 2026

Failing with original bug id #78095

https://platform.applause.com/services/links/v1/external/ad2d8d96e7ab36505598578f5a62dd7002da73ba20bc86b5541c21ef1333efeb

https://platform.applause.com/services/links/v1/external/19e3ce81e44056d7a205e6ec8d2c3ce727de8078b8b42d66c16b5d0ce3bb60ad

I just verified this on the latest staging v9.2.99-1, the functionality still works. @kavimuru could you please try verifying it again on latest staging? and does it only happen on the windows version? Thank you.

CleanShot.2026-01-12.at.19.50.36.mp4

@btkcodedev Could you please take a look this one with latest main?

@btkcodedev
Copy link
Contributor Author

@suneox It is fully working for me as expected on the main branch. 🙇
CC: @kavimuru

Screen.Recording.2026-01-12.at.8.24.12.PM.mov

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/francoisl in version: 9.2.99-8 🚀

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

@btkcodedev btkcodedev deleted the btkcodedev/78095CommaSpanish branch March 13, 2026 07:10
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.

6 participants