Remove Onyx.connect() for the key: ONYXKEYS.COUNTRY_CODE in src/libs/LocalePhoneNumber.ts #86244
Remove Onyx.connect() for the key: ONYXKEYS.COUNTRY_CODE in src/libs/LocalePhoneNumber.ts #86244FitseTLT wants to merge 2 commits intoExpensify:mainfrom
Conversation
|
@shubham1206agra 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] |
|
|
|
@FitseTLT This is not a correct fix as there are many calls you missed when refactoring. |
| * and an internationally converted phone number with the country code for numbers from other regions | ||
| */ | ||
| function formatPhoneNumberWithCountryCode(number: string, countryCodeByIP: number): string { | ||
| function formatPhoneNumber(number: string, countryCode: number = CONST.DEFAULT_COUNTRY_CODE): string { |
There was a problem hiding this comment.
| function formatPhoneNumber(number: string, countryCode: number = CONST.DEFAULT_COUNTRY_CODE): string { | |
| function formatPhoneNumber(number: string, countryCode: number): string { |
This is a required param. We should not use default here.
|
@FitseTLT Also, do this PR in parts as it will be easier to migrate. Use |
What do you mean? Totally remove formatPhoneNumber in LocalPhoneNumber? I was just following the instruction in the OP. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: de5241b38a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| * and an internationally converted phone number with the country code for numbers from other regions | ||
| */ | ||
| function formatPhoneNumberWithCountryCode(number: string, countryCodeByIP: number): string { | ||
| function formatPhoneNumber(number: string, countryCode: number = CONST.DEFAULT_COUNTRY_CODE): string { |
There was a problem hiding this comment.
Preserve dynamic country code in default phone formatter
This change makes formatPhoneNumber() fall back to CONST.DEFAULT_COUNTRY_CODE when no country is passed, but most existing callers still invoke it with a single argument (for example in src/libs/UserUtils.ts, src/libs/ReportActionsUtils.ts, and multiple pages/components). Since the Onyx.connect subscription was removed here, those callers now behave as if the user is always in country code 1, so non-US users will see same-country phone logins formatted internationally across the app. Please keep the default path tied to the current Onyx country code or migrate all one-arg call sites to pass COUNTRY_CODE explicitly.
Useful? React with 👍 / 👎.
|
|
||
| if (currentOwner) { | ||
| const ownerItem = createUserListItem(ownerPersonalDetails, currentOwner, 'currentOwner', true); | ||
| const ownerItem = createUserListItem(ownerPersonalDetails, currentOwner, 'currentOwner', countryCode, true); |
There was a problem hiding this comment.
Include country code in sections memo dependencies
The sections useMemo now formats owner/current-user logins with countryCode, but countryCode is missing from the dependency array. If ONYXKEYS.COUNTRY_CODE hydrates after initial render (e.g., cold start/session restore), this memo will not recompute and these rows can remain incorrectly formatted until another dependency changes. Add countryCode to the memo dependencies so formatting updates reliably.
Useful? React with 👍 / 👎.
Explanation of Change
Fixed Issues
$ #66327
PROPOSAL:
Tests
Precondition
If the approver's phone number is in the same country as the current user, it should be formatted locally
If the approver's phone number is not in the same country as the current user, it should be formatted internationally (like +1352...)
Verify that no errors appear in the JS console
Offline tests
same as tests
QA Steps
same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
2026-03-24.19-02-46.mp4