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
[$175] Phone-number validation error displayed when set 9833330123 as phone number #104964
Version Number: 9.5.20-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:#104372 Email or phone of affected tester (no customers):gocemate+workseee5@gmail.com Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: windows 10/chrome App Component: User Settings
Action Performed:
Open Personal information under profile settings.
Complete the other required fields with valid test data of US address.
appendCountryCode adds +<IP country code>. If that result isn't a possible number, the function adds only +. In that case, 9833330123 becomes +9833330123, which reads as an Iranian (+98) number that is too short.
Upgrade awesome-phonenumber to 6.11.0 so newer US area codes like 983 validate is in 9.5.20-0. It fixed +19833330123, so the number works when the code adds +1. The tester is likely outside the US, so the code never adds +1. That PR's author was likely on a US IP, which explains why the same steps passed for them.
Saving has the same flaw. updatePrivatePersonalDetails formats the number with the IP country code. For example, a user in India with a US address would save +919833330123.
What changes do you think we should make in order to solve the problem?
When the user hasn't typed a +, derive the calling code from the address country selected in the form. For example, use getCountryCodeForRegionCode('US') from awesome-phonenumber to get 1. Fall back to the Onyx countryCode only when no address country is selected.
Add a small LoginUtils helper that takes the phone, the region, and the fallback code.
Use the helper in PrivatePersonalDetailsPage validation and in updatePrivatePersonalDetails so validation and the saved E.164 value match.
Add a unit test: 9833330123 with country US and an IP code of 44 should be valid and format to +19833330123.
What alternative solutions did you explore? (Optional)
Stop the +${phone} fallback in appendCountryCode. This would hide the bad +98 parse, but it wouldn't add the correct +1. The number would still be saved with the wrong country code.
Confidence and open questions
Confidence is medium. The code path is confirmed. I didn't confirm the tester's IP-based countryCode, and I didn't run the library against +<tester code>9833330123. You can confirm the cause if you see either of these:
The tester's Onyx countryCode is not 1.
Running Onyx.set('countryCode', 44) on a US IP reproduces the error.
If the tester's countryCode is 1, this root cause is wrong.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/104964) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
changed the title [-]Phone-number validation error displayed when set 9833330123 as phone number[/-][+][$175] Phone-number validation error displayed when set 9833330123 as phone number[/+]on Oct 26, 2026
Please re-state the problem that we are trying to solve in this issue.
In Settings > Profile > Personal information (PrivatePersonalDetailsPage) — and in the MissingPersonalDetails card-shipping/reveal wizard (MissingPersonalDetails/subPages/PhoneNumber.tsx) — entering a 10-digit US phone number without a +1 prefix (such as 9833330123) while a US address is selected ignores the form's selected address country and uses the client's IP geolocation calling code (ONYXKEYS.COUNTRY_CODE). Depending on the user's IP calling code, this either triggers the "Please enter a valid phone number" validation error (e.g., countryCode = 48 or 380) or silently formats and saves the number under a foreign calling code (e.g., +449833330123 or +919833330123).
What is the root cause of that problem?
PR #104372 upgraded awesome-phonenumber to 6.11.0, so +19833330123 is valid when the +1 calling code is prepended.
In src/libs/LoginUtils.ts (appendCountryCode), testing 9833330123 against awesome-phonenumber@6.11.0 and the app's parsePhoneNumber / isValidPhoneNumber produces two failure modes when countryCode !== 1:
IP countryCode
appendCountryCode('9833330123', countryCode)
isValidPhoneNumber (.possible)
formatE164PhoneNumber output
1 (US)
+19833330123
true
+19833330123
48 (PL), 380 (UA)
+9833330123 (+48.../+380... is not possible -> falls back to +${phone}, parsed as Iran +98 with 8 digits)
false (throws validation error)
+9833330123
44 (GB), 49 (DE), 91 (IN)
+449833330123 / +499833330123 / +919833330123
true (silently misinterprets US number as foreign number)
+449833330123 / +499833330123 / +919833330123
There are five coupled call sites across validation, step-draft formatting, and API submission that must stay in sync:
Site 3 — MissingPersonalDetails step onSubmit draft formatting:src/pages/MissingPersonalDetails/subPages/PhoneNumber.tsx:60 calls formatE164PhoneNumber(values[INPUT_IDS.PHONE_NUMBER].trim(), countryCode)before saving the step value into ONYXKEYS.FORMS.PERSONAL_DETAILS_FORM_DRAFT. If line 60 is not updated alongside validation, submitting the phone step on IP 91 or 44 writes +919833330123 / +449833330123 (with a leading +) into the draft, and later calls to appendCountryCode will return it unchanged because phone.startsWith('+') is already true.
Site 4 — Profile submission:updatePrivatePersonalDetails in src/libs/actions/PersonalDetails.ts calls LoginUtils.formatE164PhoneNumber(values.phoneNumber?.trim() ?? '', countryCode).
Site 5 — Card shipping / reveal submission:buildSetPersonalDetailsAndShipExpensifyCardsParams in src/libs/actions/PersonalDetails.ts (shared by updatePersonalDetailsAndShipExpensifyCards, MissingPersonalDetailsContent.tsx, MissingPersonalDetailsValidateCodePage.tsx, ExpensifyCardVerifyAccountPage.tsx, and ExpensifyCardPage/index.tsx) also calls LoginUtils.formatE164PhoneNumber(values.phoneNumber?.trim() ?? '', countryCode).
What changes do you think we should make in order to solve the problem?
When the phone input does not have an explicit + calling code, resolve the default calling code from the selected address country first, falling back to ONYXKEYS.COUNTRY_CODE when no valid address country is present.
Add and export getPhoneCallingCode in src/libs/LoginUtils.ts:
(no-restricted-imports in config/eslint/eslint.config.mjs only restricts parsePhoneNumber from awesome-phonenumber, so getCountryCodeForRegionCode can be imported directly; normalizing via getCountryCode from @libs/CountryUtils handles legacy stored country names like 'United States'):
In src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx:
Move the existing const effectiveCountry = values[INPUT_IDS.COUNTRY] ?? ''; declaration (currently at line 155) above the phone validation block (line 134) and pass getPhoneCallingCode(effectiveCountry, countryCode):
In src/pages/MissingPersonalDetails/subPages/PhoneNumber.tsx:
Because an existing address country may come from stored privatePersonalDetails (normalized in MissingPersonalDetailsContent.tsx via personalDetailsValues) rather than draftValues, compute effectiveCountryCode from personalDetailsValues[INPUT_IDS.COUNTRY] and use it in bothvalidate (line 29) and onSubmit (line 60):
In src/libs/actions/PersonalDetails.ts:
Update both buildSetPersonalDetailsAndShipExpensifyCardsParams (line 61) and updatePrivatePersonalDetails (line 547):
With country = 'US' and IP countryCode = 48 (which previously failed validation as +9833330123) or 91 (which previously misformatted as +919833330123), appendCountryCode and formatE164PhoneNumber produce '+19833330123', while explicit international input like '+442071234567' remains '+442071234567'.
What alternative solutions did you explore? (Optional)
Updating only PhoneNumber.tsx validation and updatePrivatePersonalDetails (as in MelvinBot's proposal): Incomplete because PhoneNumber.tsx:60 formats the number with countryCode before writing to the form draft, and buildSetPersonalDetailsAndShipExpensifyCardsParams formats the number with countryCode when submitting the card-shipping/reveal flow.
Falling back to CONST.DEFAULT_COUNTRY_CODE (1) inside appendCountryCode: Rejected because it breaks non-US addresses and affects 25+ unrelated login/invite/wallet call sites across the app.
Please re-state the problem that we are trying to solve in this issue.
In Settings > Profile > Personal information (PrivatePersonalDetailsPage), entering a 10-digit US phone number without the +1 prefix (e.g., 9833330123) alongside a US address displays the validation error "Please enter a valid phone number" whenever the user's IP geolocation calling code (ONYXKEYS.COUNTRY_CODE) is outside North America.
What is the root cause of that problem?
In src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx (lines 134–142):
countryCode is obtained on line 58 directly from useOnyx(ONYXKEYS.COUNTRY_CODE) (which is set by the backend based on the client's current IP geolocation, e.g. 380 for Ukraine, 48 for Poland, 44 for UK, 91 for India).
In src/libs/LoginUtils.ts (appendCountryCode, lines 22–31):
When an offshore QA tester or international user tests/enters a 10-digit US number without +1 (such as 9833330123):
appendCountryCode first attempts +${countryCode}${phone} (e.g. +3809833330123 or +489833330123). Because local phone numbers in those countries expect 9 digits, 10 digits makes parsePhoneNumber.possible return false.
appendCountryCode then falls back to +${phone} (+9833330123).
In awesome-phonenumber, +98 is the country calling code for Iran (IR). Because Iranian phone numbers require 10 digits after +98, having only 8 digits (33330123) makes parsePhoneNumber('+9833330123').possible return false.
isValidPhoneNumber('+9833330123') returns false, causing PrivatePersonalDetailsPage to flag errors[INPUT_IDS.PHONE_NUMBER].
A matching issue exists upon submission in src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsConfirmValidateCodePage.tsx (lines 28 and 70):
In src/libs/actions/PersonalDetails.ts (line 547), formatE164PhoneNumber(values.phoneNumber?.trim() ?? '', countryCode) uses the passed countryCode to normalize the E.164 phone number. Because countryCode is the IP geolocation, it also fails or formats incorrectly when the user entered a national number matching their selected address country.
What changes do you think we should make in order to solve the problem?
In src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx:
Derive the phone number's country calling code from the address country (values[INPUT_IDS.COUNTRY]), falling back to countryCode (from ONYXKEYS.COUNTRY_CODE) or CONST.DEFAULT_COUNTRY_CODE (1):
In src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsConfirmValidateCodePage.tsx:
Derive the calling code passed to updatePrivatePersonalDetails from the draft's address country (values.country === CONST.COUNTRY.US ? CONST.DEFAULT_COUNTRY_CODE : countryCode) so the normalized E.164 value in LoginUtils.formatE164PhoneNumber is also consistently formatted as +19833330123.
In src/libs/LoginUtils.ts (appendCountryCode):
As a secondary safeguard, when parsePhoneNumber('+${countryCode}${phone}').possible is false, check whether parsePhoneNumber('+${CONST.DEFAULT_COUNTRY_CODE}${phone}').possible is true before falling back to +${phone}. This ensures standard 10-digit North American numbers gracefully normalize to +1 across all callers even if a component does not explicitly override the calling code.
What alternative solutions did you explore? (Optional)
Only modifying appendCountryCode: While falling back to CONST.DEFAULT_COUNTRY_CODE in appendCountryCode resolves validation, PrivatePersonalDetailsPage and PrivatePersonalDetailsConfirmValidateCodePage are explicitly tied to the user's selected address country. Using effectiveCallingCode ensures the validation and submission payloads align with the country selected on the form.
Please re-state the problem that we are trying to solve in this issue.
On Profile > Personal information, entering 9833330123 (no +1 prefix) while a US address is selected shows a phone-number validation error, even though the number should be valid for the selected US address.
What is the root cause of that problem?
The phone check does not use the address country selected in the form. Verified on main in src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx: line 58 reads countryCode from ONYXKEYS.COUNTRY_CODE, which is the IP-geolocation calling code, and the validate function (around line 138) calls appendCountryCode(phoneValue, countryCode) and then isValidPhoneNumber on the result. The form's selected country (values[INPUT_IDS.COUNTRY], used as effectiveCountry for the zip-code check just below) is never used for the phone check. So when the IP calling code disagrees with the selected address country, validation prefixes the wrong calling code, and a valid US number fails. This holds regardless of the tester's exact IP code, which is why the fix removes the IP dependence instead of chasing one tester's location.
What changes do you think we should make to fix this issue?
In the validate function of PrivatePersonalDetailsPage.tsx, derive the calling code from the form's selected country first: look up the calling code for values[INPUT_IDS.COUNTRY] from the app's existing country data, falling back to the Onyx countryCode only when the form country is empty. Pass that code to appendCountryCode and keep the existing isValidPhoneNumber gate unchanged, so genuinely invalid numbers still error and no number is silently re-addressed to a different country.
What alternative solutions did you explore? (Optional)
Leaving the IP-based code and special-casing US numbers was rejected: it would fix only this one number and would still mis-validate every other form-country/IP mismatch.
What will you verify?
US form country with a non-US IP calling code, entering 9833330123: no validation error (the failing case).
US form country with a US IP calling code, same number: still no error.
A genuinely invalid number under a US form country: still errors.
A non-US form country: validation uses that country's code, not the IP code.
Existing PersonalDetails form tests pass, plus a new unit test for the form-country/IP mismatch case.
Bare phone numbers (no +) now use the calling code of the address country in the form. The IP-based code is only a fallback.
I confirmed the cause on main. With a Ukrainian IP code (380), 9833330123 becomes +9833330123 and fails validation. UK and India IP codes pass but save the wrong calling code, for example +449833330123.
The fix covers Profile > Personal information (validation and save), the Missing Personal Details phone step, and the Expensify Card save path.
It also handles the points emkhalid raised. Legacy country names like "United States" resolve correctly. The Missing Personal Details phone step reads the country from the saved form values. The phone library stays wrapped in @libs/PhoneNumber.
Testing
Unit tests (LoginUtilsTest, CloseAccountPageTest), typecheck, and lint passed.
I couldn't run the web UI check because the test browser session showed a blank page. To check manually, run Onyx.set('countryCode', 380), then enter 9833330123 with a US address on Profile > Personal information.
@parasharrajat this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
Activity
applause-bot commentedon Oct 26, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/1987a4ffa16c0d3cd8e16fc432dbf58243987ba6a734d409783d64862cfcd58c
MelvinBot commentedon Oct 26, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Profile > Personal information, entering
9833330123with a US address shows a phone-number error.What is the root cause of that problem?
The phone check ignores the US address. Instead, it adds the calling code from the Onyx
countryCodekey, which comes from the user's IP location.PrivatePersonalDetailsPage.tsx:138callsappendCountryCode(phoneValue, countryCode).countryCodecomes fromONYXKEYS.COUNTRY_CODE(line 58).appendCountryCodeadds+<IP country code>. If that result isn't a possible number, the function adds only+. In that case,9833330123becomes+9833330123, which reads as an Iranian (+98) number that is too short.isValidPhoneNumberthen rejects it.Upgrade awesome-phonenumber to 6.11.0 so newer US area codes like 983 validate is in 9.5.20-0. It fixed
+19833330123, so the number works when the code adds+1. The tester is likely outside the US, so the code never adds+1. That PR's author was likely on a US IP, which explains why the same steps passed for them.Saving has the same flaw.
updatePrivatePersonalDetailsformats the number with the IP country code. For example, a user in India with a US address would save+919833330123.What changes do you think we should make in order to solve the problem?
When the user hasn't typed a
+, derive the calling code from the address country selected in the form. For example, usegetCountryCodeForRegionCode('US')from awesome-phonenumber to get1. Fall back to the OnyxcountryCodeonly when no address country is selected.LoginUtilshelper that takes the phone, the region, and the fallback code.PrivatePersonalDetailsPagevalidation and inupdatePrivatePersonalDetailsso validation and the saved E.164 value match.MissingPersonalDetails/subPages/PhoneNumber.tsx, which uses the same pattern.9833330123with countryUSand an IP code of44should be valid and format to+19833330123.What alternative solutions did you explore? (Optional)
Stop the
+${phone}fallback inappendCountryCode. This would hide the bad +98 parse, but it wouldn't add the correct+1. The number would still be saved with the wrong country code.Confidence and open questions
Confidence is medium. The code path is confirmed. I didn't confirm the tester's IP-based
countryCode, and I didn't run the library against+<tester code>9833330123. You can confirm the cause if you see either of these:countryCodeis not1.Onyx.set('countryCode', 44)on a US IP reproduces the error.If the tester's
countryCodeis1, this root cause is wrong.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/104964)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run
melvin-bot commentedon Oct 26, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @parasharrajat (
External)[-]Phone-number validation error displayed when set 9833330123 as phone number[/-][+][$175] Phone-number validation error displayed when set 9833330123 as phone number[/+]melvin-bot commentedon Oct 26, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022114601454992118674
camesenin commentedon Oct 26, 2026
melvin-bot commentedon Oct 26, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
shilo1979jk commentedon Oct 26, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
In Settings > Profile > Personal information (
PrivatePersonalDetailsPage) — and in the MissingPersonalDetails card-shipping/reveal wizard (MissingPersonalDetails/subPages/PhoneNumber.tsx) — entering a 10-digit US phone number without a+1prefix (such as9833330123) while a US address is selected ignores the form's selected address country and uses the client's IP geolocation calling code (ONYXKEYS.COUNTRY_CODE). Depending on the user's IP calling code, this either triggers the "Please enter a valid phone number" validation error (e.g.,countryCode = 48or380) or silently formats and saves the number under a foreign calling code (e.g.,+449833330123or+919833330123).What is the root cause of that problem?
PR #104372 upgraded
awesome-phonenumberto6.11.0, so+19833330123is valid when the+1calling code is prepended.However, in
src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx, phone validation ignores the country selected on the form (values[INPUT_IDS.COUNTRY]) and passescountryCodefromuseOnyx(ONYXKEYS.COUNTRY_CODE)(IP geolocation):In
src/libs/LoginUtils.ts(appendCountryCode), testing9833330123againstawesome-phonenumber@6.11.0and the app'sparsePhoneNumber/isValidPhoneNumberproduces two failure modes whencountryCode !== 1:countryCodeappendCountryCode('9833330123', countryCode)isValidPhoneNumber(.possible)formatE164PhoneNumberoutput1(US)+19833330123true+1983333012348(PL),380(UA)+9833330123(+48.../+380...is not possible -> falls back to+${phone}, parsed as Iran+98with 8 digits)false(throws validation error)+983333012344(GB),49(DE),91(IN)+449833330123/+499833330123/+919833330123true(silently misinterprets US number as foreign number)+449833330123/+499833330123/+919833330123There are five coupled call sites across validation, step-draft formatting, and API submission that must stay in sync:
PrivatePersonalDetailsPage.tsx:138(appendCountryCode(phoneValue, countryCode)).src/pages/MissingPersonalDetails/subPages/PhoneNumber.tsx:29(appendCountryCode(values[INPUT_IDS.PHONE_NUMBER], countryCode)).onSubmitdraft formatting:src/pages/MissingPersonalDetails/subPages/PhoneNumber.tsx:60callsformatE164PhoneNumber(values[INPUT_IDS.PHONE_NUMBER].trim(), countryCode)before saving the step value intoONYXKEYS.FORMS.PERSONAL_DETAILS_FORM_DRAFT. If line 60 is not updated alongside validation, submitting the phone step on IP91or44writes+919833330123/+449833330123(with a leading+) into the draft, and later calls toappendCountryCodewill return it unchanged becausephone.startsWith('+')is alreadytrue.updatePrivatePersonalDetailsinsrc/libs/actions/PersonalDetails.tscallsLoginUtils.formatE164PhoneNumber(values.phoneNumber?.trim() ?? '', countryCode).buildSetPersonalDetailsAndShipExpensifyCardsParamsinsrc/libs/actions/PersonalDetails.ts(shared byupdatePersonalDetailsAndShipExpensifyCards,MissingPersonalDetailsContent.tsx,MissingPersonalDetailsValidateCodePage.tsx,ExpensifyCardVerifyAccountPage.tsx, andExpensifyCardPage/index.tsx) also callsLoginUtils.formatE164PhoneNumber(values.phoneNumber?.trim() ?? '', countryCode).What changes do you think we should make in order to solve the problem?
When the phone input does not have an explicit
+calling code, resolve the default calling code from the selected address country first, falling back toONYXKEYS.COUNTRY_CODEwhen no valid address country is present.Add and export
getPhoneCallingCodeinsrc/libs/LoginUtils.ts:(
no-restricted-importsinconfig/eslint/eslint.config.mjsonly restrictsparsePhoneNumberfromawesome-phonenumber, sogetCountryCodeForRegionCodecan be imported directly; normalizing viagetCountryCodefrom@libs/CountryUtilshandles legacy stored country names like'United States'):In
src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx:Move the existing
const effectiveCountry = values[INPUT_IDS.COUNTRY] ?? '';declaration (currently at line 155) above the phone validation block (line 134) and passgetPhoneCallingCode(effectiveCountry, countryCode):In
src/pages/MissingPersonalDetails/subPages/PhoneNumber.tsx:Because an existing address country may come from stored
privatePersonalDetails(normalized inMissingPersonalDetailsContent.tsxviapersonalDetailsValues) rather thandraftValues, computeeffectiveCountryCodefrompersonalDetailsValues[INPUT_IDS.COUNTRY]and use it in bothvalidate(line 29) andonSubmit(line 60):validate(with[translate, effectiveCountryCode]dependencies):onSubmit(line 60):In
src/libs/actions/PersonalDetails.ts:Update both
buildSetPersonalDetailsAndShipExpensifyCardsParams(line 61) andupdatePrivatePersonalDetails(line 547):Add unit tests in
tests/unit/LoginUtilsTest.ts(and personal details action/step tests):getPhoneCallingCode('US', 48)andgetPhoneCallingCode('United States', 48)return1;getPhoneCallingCode('', 48)returns48.country = 'US'and IPcountryCode = 48(which previously failed validation as+9833330123) or91(which previously misformatted as+919833330123),appendCountryCodeandformatE164PhoneNumberproduce'+19833330123', while explicit international input like'+442071234567'remains'+442071234567'.What alternative solutions did you explore? (Optional)
PhoneNumber.tsxvalidation andupdatePrivatePersonalDetails(as in MelvinBot's proposal): Incomplete becausePhoneNumber.tsx:60formats the number withcountryCodebefore writing to the form draft, andbuildSetPersonalDetailsAndShipExpensifyCardsParamsformats the number withcountryCodewhen submitting the card-shipping/reveal flow.CONST.DEFAULT_COUNTRY_CODE(1) insideappendCountryCode: Rejected because it breaks non-US addresses and affects 25+ unrelated login/invite/wallet call sites across the app.bhomvratrai-glitch commentedon Oct 26, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
In Settings > Profile > Personal information (
PrivatePersonalDetailsPage), entering a 10-digit US phone number without the+1prefix (e.g.,9833330123) alongside a US address displays the validation error "Please enter a valid phone number" whenever the user's IP geolocation calling code (ONYXKEYS.COUNTRY_CODE) is outside North America.What is the root cause of that problem?
In
src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx(lines 134–142):countryCodeis obtained on line 58 directly fromuseOnyx(ONYXKEYS.COUNTRY_CODE)(which is set by the backend based on the client's current IP geolocation, e.g.380for Ukraine,48for Poland,44for UK,91for India).In
src/libs/LoginUtils.ts(appendCountryCode, lines 22–31):When an offshore QA tester or international user tests/enters a 10-digit US number without
+1(such as9833330123):appendCountryCodefirst attempts+${countryCode}${phone}(e.g.+3809833330123or+489833330123). Because local phone numbers in those countries expect 9 digits, 10 digits makesparsePhoneNumber.possiblereturnfalse.appendCountryCodethen falls back to+${phone}(+9833330123).awesome-phonenumber,+98is the country calling code for Iran (IR). Because Iranian phone numbers require 10 digits after+98, having only 8 digits (33330123) makesparsePhoneNumber('+9833330123').possiblereturnfalse.isValidPhoneNumber('+9833330123')returnsfalse, causingPrivatePersonalDetailsPageto flagerrors[INPUT_IDS.PHONE_NUMBER].A matching issue exists upon submission in
src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsConfirmValidateCodePage.tsx(lines 28 and 70):In
src/libs/actions/PersonalDetails.ts(line 547),formatE164PhoneNumber(values.phoneNumber?.trim() ?? '', countryCode)uses the passedcountryCodeto normalize the E.164 phone number. BecausecountryCodeis the IP geolocation, it also fails or formats incorrectly when the user entered a national number matching their selected address country.What changes do you think we should make in order to solve the problem?
In
src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx:Derive the phone number's country calling code from the address country (
values[INPUT_IDS.COUNTRY]), falling back tocountryCode(fromONYXKEYS.COUNTRY_CODE) orCONST.DEFAULT_COUNTRY_CODE(1):In
src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsConfirmValidateCodePage.tsx:Derive the calling code passed to
updatePrivatePersonalDetailsfrom the draft's address country (values.country === CONST.COUNTRY.US ? CONST.DEFAULT_COUNTRY_CODE : countryCode) so the normalized E.164 value inLoginUtils.formatE164PhoneNumberis also consistently formatted as+19833330123.In
src/libs/LoginUtils.ts(appendCountryCode):As a secondary safeguard, when
parsePhoneNumber('+${countryCode}${phone}').possibleisfalse, check whetherparsePhoneNumber('+${CONST.DEFAULT_COUNTRY_CODE}${phone}').possibleistruebefore falling back to+${phone}. This ensures standard 10-digit North American numbers gracefully normalize to+1across all callers even if a component does not explicitly override the calling code.What alternative solutions did you explore? (Optional)
appendCountryCode: While falling back toCONST.DEFAULT_COUNTRY_CODEinappendCountryCoderesolves validation,PrivatePersonalDetailsPageandPrivatePersonalDetailsConfirmValidateCodePageare explicitly tied to the user's selected address country. UsingeffectiveCallingCodeensures the validation and submission payloads align with the country selected on the form.khizzcr7 commentedon Oct 26, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Profile > Personal information, entering
9833330123(no+1prefix) while a US address is selected shows a phone-number validation error, even though the number should be valid for the selected US address.What is the root cause of that problem?
The phone check does not use the address country selected in the form. Verified on
maininsrc/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx: line 58 readscountryCodefromONYXKEYS.COUNTRY_CODE, which is the IP-geolocation calling code, and the validate function (around line 138) callsappendCountryCode(phoneValue, countryCode)and thenisValidPhoneNumberon the result. The form's selected country (values[INPUT_IDS.COUNTRY], used aseffectiveCountryfor the zip-code check just below) is never used for the phone check. So when the IP calling code disagrees with the selected address country, validation prefixes the wrong calling code, and a valid US number fails. This holds regardless of the tester's exact IP code, which is why the fix removes the IP dependence instead of chasing one tester's location.What changes do you think we should make to fix this issue?
In the validate function of
PrivatePersonalDetailsPage.tsx, derive the calling code from the form's selected country first: look up the calling code forvalues[INPUT_IDS.COUNTRY]from the app's existing country data, falling back to the OnyxcountryCodeonly when the form country is empty. Pass that code toappendCountryCodeand keep the existingisValidPhoneNumbergate unchanged, so genuinely invalid numbers still error and no number is silently re-addressed to a different country.What alternative solutions did you explore? (Optional)
Leaving the IP-based code and special-casing US numbers was rejected: it would fix only this one number and would still mis-validate every other form-country/IP mismatch.
What will you verify?
9833330123: no validation error (the failing case).8 remaining items
melvin-bot commentedon Nov 3, 2026
@parasharrajat 6 days overdue. This is scarier than being forced to listen to Vogon poetry!
parasharrajat commentedon Nov 3, 2026
@MelvinBot implement this #104964 (comment)
🎀 👀 🎀 C+ reviewed
MelvinBot commentedon Nov 3, 2026
🤖 Draft PR created: Use the address country's calling code when validating personal details phone numbers
Please mark it as "Ready for review" or ask me to do that for you when it is ready for review.
Bare phone numbers (no
+) now use the calling code of the address country in the form. The IP-based code is only a fallback.main. With a Ukrainian IP code (380),9833330123becomes+9833330123and fails validation. UK and India IP codes pass but save the wrong calling code, for example+449833330123.emkhalidraised. Legacy country names like "United States" resolve correctly. The Missing Personal Details phone step reads the country from the saved form values. The phone library stays wrapped in@libs/PhoneNumber.Testing
LoginUtilsTest,CloseAccountPageTest), typecheck, and lint passed.Onyx.set('countryCode', 380), then enter9833330123with a US address on Profile > Personal information.melvin-bot commentedon Nov 6, 2026
@parasharrajat Whoops! This issue is 2 days overdue. Let's get this updated quick!
jeffrey-graham commentedon Nov 7, 2026
melvin-bot commentedon Nov 7, 2026
melvin-bot commentedon Nov 9, 2026
@parasharrajat this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
melvin-bot commentedon Nov 10, 2026
@parasharrajat Still overdue 6 days?! Let's take care of this!
melvin-bot commentedon Nov 12, 2026
@parasharrajat 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!
expensify-chore-bot commentedon Nov 19, 2026
This issue has not been updated in over 14 days. @parasharrajat eroding to Weekly issue.