App icon indicating copy to clipboard operation
App copied to clipboard

[Due for payment 2026-11-25] [$175] Address - error displayed in verification code flow, and not indicating the invalid state

Open lanitochka17 opened this issue 1 month ago • 33 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.5.16-1 Reproducible in staging?: Yes Reproducible in production?: yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://github.com/Expensify/Expensify/issues/437029 Email or phone of affected tester (no customers): Issue reported by: Applause Internal Team Bug source: Device used: App Component:

Action Performed:

  1. Go to Account settings > Profile > Address.
  2. Select a US address.
  3. Click Country and select United Kingdom.
  4. Enter anything in State field and click Save (ignore the incorrect zip code).
  5. Click Country and select United States.
  6. Without selecting State, click Save

Expected Result:

the "State" field is empty after selecting the U.S. again, and when you click "Save," an error message appears indicating that the state is invalid.

Actual Result:

error message displayed in verification code flow, and not indicating the invalid state. it says "Oops something went wrong and your request could not be completed. Please try again later."

Workaround:

Unknown

Platforms:

  • [ ] Android: App
  • [ ] Android: mWeb Chrome
  • [ ] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [ ] MacOS: Chrome / Safari

Screenshots/Videos

https://github.com/user-attachments/assets/2d3be556-38b7-4575-8ced-77d2405c2305

View all open jobs on GitHub

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

lanitochka17 avatar Oct 22 '26 15:10 lanitochka17

Proposal

What is the root cause of that problem?

When you switch Country back to United States, the page keeps the free-text UK state (for example, "London") in the form.

  • The country handler only clears State when you switch to a non-US country. When you switch to US, it keeps the old value (PrivatePersonalDetailsPage.tsx:411-416). resolveStateCode returns unmatched text unchanged (:44-50).
  • StateSelector shows a blank title for any value that isn't a US state code (StateSelector.tsx:76). The field looks empty, but it still holds "London".
  • Validation only checks that State is non-empty (:154-158), so the form passes and opens the magic-code page.
  • The API sends addressCountry=US with an invalid addressState. The failure handler always shows common.genericErrorMessage (PersonalDetails.ts:586). That is the "Oops… something went wrong" message.

This gap came from Re-apply secure private personal details + fix 4 blockers from previous revert. [CP staging] Fix: state field not cleared when address country changes to non-US fixed only the US → non-US direction.

What changes do you think we should make in order to solve the problem?

  1. In the Country onValueChange handler, when the new country is US, keep the resolved value only if it is a valid key in COMMON_CONST.STATES. Otherwise, clear selectedState and the State draft value, as the non-US branch already does. This still turns "California" into "CA".
  2. In validate, when the country is US and the State value is not a valid key in COMMON_CONST.STATES, show the State field error. This also covers an invalid US state already stored on the account.

What alternative solutions did you explore? (Optional)

Show the server's own error in the updatePrivatePersonalDetails failure path instead of the hard-coded generic message. This makes errors clearer but doesn't stop the bad request, so it would be an addition to the fix, not a replacement.

Reproduction on web (dev)

After switching UK → US, State looks empty. On Save, every empty required field shows "This field is required" except State. That matches a non-empty hidden value. The test didn't reach the server error because the UK save was blocked by the zip check and the magic code couldn't be entered.

State looks empty after switching back to US Every required field shows an error except State

Not verified: the exact backend error for an invalid US addressState. The client code supports this explanation.

Possibly related: [$175] Web - Profile - State URL parameter does not override the existing State value


Next Steps for Contributor+ team: To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/104761) to create a draft PR. To refine: @MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.


view run · view recording

MelvinBot avatar Oct 22 '26 15:10 MelvinBot

Proposal

Please re-state the problem that we are trying to solve in this issue.

On Settings > Profile > Address, the user switches Country from US to United Kingdom and types free text into the State field. They then switch Country back to United States and press Save without choosing a state.

  • Expected: the State dropdown is empty and the form shows an inline "State is required/invalid" error. No request is sent.
  • Actual: the form submits and the verification-code step opens. The backend rejects the request, and the generic "Oops something went wrong and your request could not be completed" error appears inside the verification-code UI, not on the State field.

What is the root cause of that problem?

The form's state value is not reset or revalidated when the country changes.

  1. For non-US countries, state is a free-text TextInput. For the US it is a StateSelector that expects a valid US state code.
  2. Switching the country does not clear the draft state value. The free-text UK value stays in the Onyx form draft.
  3. StateSelector finds no matching US state, so it looks empty. The underlying value is still the stale string.
  4. AddressForm.validate only checks that state is truthy for US addresses (!values.state). The stale string passes, so the form submits.
  5. The backend rejects the invalid state code. The page already sits behind the validate-code flow, so the generic API error appears there and is not tied to the State field.

I could not check the code in this environment. File and function names below follow the usual AddressForm / PersonalAddressPage layout and may differ slightly.

What changes do you think we should make in order to solve the problem?

Make two changes in src/components/AddressForm.tsx: clear the stale value on country change, and validate that the state is real.

1. Clear state when the country changes.

const handleAddressChange = useCallback((value: unknown, key: unknown) => {
    // ...existing logic
    if (key === 'country' && value !== country) {
        // Free-text state from one country is meaningless in another
        FormActions.setDraftValues(ONYXKEYS.FORMS.HOME_ADDRESS_FORM, {state: ''});
        // or: formRef.current?.resetForm({state: ''}) depending on the form wrapper in use
        setState('');
    }
    // ...
}, [country]);

This applies to every form that uses AddressForm, because the clearing lives in the shared component.

2. Validate the state, not just its presence.

const validate = useCallback((values: FormOnyxValues<typeof formID>) => {
    const errors: Errors = {};
    // ...existing required-field checks

    if (values.country === CONST.COUNTRY.US) {
        const stateCode = (values.state ?? '').trim();
        if (!stateCode) {
            errors.state = translate('common.error.fieldRequired');
        } else if (!Object.keys(COMMON_CONST.STATES).includes(stateCode)) {
            // Stale or free-text value that is not a US state
            errors.state = translate('common.error.invalidState'); // add the string if it does not exist, or reuse fieldRequired
        }
    }
    // ...
}, [translate]);

Use the same check for any other country that renders a fixed state or province list, if there is one. Also make sure StateSelector receives errorText={errors.state} so the message shows on the field.

3. (Optional) Keep the error out of the verification-code UI. With the two changes above, an invalid state never reaches the server. No change to the validate-code flow is needed for this bug.

What alternative solutions did you explore? (Optional)

  • Only clear the state on country change. This fixes the reported steps, but a stale or invalid draft could still come from other paths such as autofill or a persisted draft. Validation is the safety net, so both changes are kept.
  • Only add validation. This blocks the bad request but leaves hidden garbage in the field and the user sees a confusing empty dropdown. Clearing the value gives better UX.
  • Handle the server error in the validate-code modal. This treats the symptom, not the cause. Client-side validation should catch it before any API call.

Testing

  1. Reproduce the steps: Address > US address > Country = United Kingdom > type "abc" in State > Save (ignore the zip error) > Country = United States > Save without choosing a state.
    • The State field is empty.
    • A State error appears inline.
    • No verification-code modal opens and no API request is sent.
  2. Switch country US → UK → US and confirm the State value is cleared each time.
  3. Choose a valid US state, then Save. It submits normally and continues to the verification-code step.
  4. Enter a valid UK address with free-text State. It still saves.
  5. Run the unit tests for AddressForm validation:
    • US with an empty state gives an error.
    • US with an invalid string such as "abc" gives an error.
    • US with "CA" gives no error.
    • Non-US with a free-text state gives no error.
  6. Smoke-test other AddressForm consumers (e.g. the wallet and workspace address forms) to confirm nothing regressed.

Abdallah-1551 avatar Oct 22 '26 15:10 Abdallah-1551

Triggered auto assignment to Contributor-plus team member for initial proposal review - @situchan (External)

melvin-bot[bot] avatar Oct 22 '26 15:10 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022113294785070727304

melvin-bot[bot] avatar Oct 22 '26 15:10 melvin-bot[bot]

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Oct 22 '26 15:10 melvin-bot[bot]

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0170d6b02e9440e604

Proposal

Please re-state the problem that we are trying to solve in this issue.

In Account settings > Profile > Address, when switching Country to a non-US country (e.g. United Kingdom), entering free text in the State field (e.g. "London"), and then switching Country back to United States: The State field appears empty, but clicking "Save" without selecting a US state bypasses client-side field validation, enters the 2FA/verification flow, and crashes with a generic error: "Oops something went wrong and your request could not be completed. Please try again later." instead of indicating an invalid state error on the State field.

What is the root cause of that problem?

  1. In src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx:411-423:
    if (newCountry === CONST.COUNTRY.US) {
        const resolved = resolveStateCode(selectedState);
        if (resolved !== selectedState) {
            setSelectedState(resolved);
        }
        return;
    }
    // A previously selected US state (or another country's value) does not apply to the new country.
    setSelectedState('');
    setDraftValues(ONYXKEYS.FORMS.PERSONAL_DETAILS_FORM, {[INPUT_IDS.STATE]: ''});
    
    When switching to a non-US country, line 421 correctly resets selectedState and clears the draft value in ONYXKEYS.FORMS.PERSONAL_DETAILS_FORM. However, when switching back to US, if selectedState currently holds arbitrary foreign text (e.g. "London"), resolveStateCode("London") fails to match any entry in COMMON_CONST.STATES and returns "London" unchanged (:50).
  2. StateSelector.tsx:76 resolves its label via stateList[state]?.stateName. Because "London" is not a valid key in COMMON_CONST.STATES, it renders a blank selector title. Visually, the user sees an empty field.
  3. In validate (lines 154–158):
    const stateValue = values[INPUT_IDS.STATE] ?? '';
    if (!stateValue.trim()) {
        errors[INPUT_IDS.STATE] = translate('common.error.fieldRequired');
    }
    
    validate only checks whether stateValue is non-empty. Because the draft still contains "London", validation succeeds! The form submits addressCountry: "US" with addressState: "London".
  4. The backend rejects this invalid combination during the update payload, resulting in a generic 500/API failure error modal ("Oops something went wrong...") inside the verification flow instead of catching the error client-side.

What changes do you think we should make in order to solve the problem?

1. In src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx:

In the Country picker's onValueChange: When switching to CONST.COUNTRY.US, ensure that the resolved state is a valid US state code in COMMON_CONST.STATES. If not, reset selectedState and update the form draft value:

--- a/src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx
+++ b/src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx
@@ -410,9 +410,9 @@ function PrivatePersonalDetailsPage() {
                                 setSelectedCountry(newCountry);
                                 if (newCountry === CONST.COUNTRY.US) {
                                     const resolved = resolveStateCode(selectedState);
-                                    if (resolved !== selectedState) {
-                                        setSelectedState(resolved);
-                                    }
+                                    const validState = resolved && resolved in COMMON_CONST.STATES ? resolved : '';
+                                    setSelectedState(validState);
+                                    setDraftValues(ONYXKEYS.FORMS.PERSONAL_DETAILS_FORM, {[INPUT_IDS.STATE]: validState});
                                     return;
                                 }
                                 // A previously selected US state (or another country's value) does not apply to the new country.

2. In validate:

Add defensive validation for effectiveCountry === CONST.COUNTRY.US: Ensure that when Country is US, the submitted state must exist in COMMON_CONST.STATES:

@@ -155,6 +155,8 @@ function PrivatePersonalDetailsPage() {
         const effectiveCountry = values[INPUT_IDS.COUNTRY] ?? '';
         if (!stateValue.trim()) {
             errors[INPUT_IDS.STATE] = translate('common.error.fieldRequired');
+        } else if (effectiveCountry === CONST.COUNTRY.US && !(stateValue in COMMON_CONST.STATES)) {
+            errors[INPUT_IDS.STATE] = translate('privatePersonalDetails.error.incorrectStateFormat');
         }

         const zipValue = values[INPUT_IDS.ZIP_POST_CODE] ?? '';

Why this solution is optimal:

  1. Immediate Draft & Visual Synchronization: Switching to US resets any invalid free-text from previous countries, so the form draft and the StateSelector reflect an empty selection.
  2. Double Defense: Even if an invalid state code was persisted or passed in from an external source, validate blocks submission client-side and highlights the State field with incorrectStateFormat before entering the 2FA flow.
  3. Preserves Valid Full State Conversions: If the user previously had "California", resolveStateCode still successfully converts it to "CA".

What alternative solutions did you explore? (Optional)

  • Only validating in validate without updating draft on Country change: Rejected. If we don't clear the draft, the dropdown looks empty to the user, but submitting would display a validation error on what appears to be an unselected field. Clearing the draft ensures the state matches the UI.

What automated tests can you add to prevent this from re-occurring?

In tests/unit/PrivatePersonalDetailsPageTest.tsx:

  1. Select Country GB, enter state: "London".
  2. Change Country to US.
  3. Assert that selectedState and form draft value for state are cleared ('').
  4. Execute validate with country: 'US' and state: 'London' and assert errors[INPUT_IDS.STATE] is defined.

camesenin avatar Oct 22 '26 15:10 camesenin

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Oct 22 '26 15:10 melvin-bot[bot]

Proposal

Please re-state the problem that we are trying to solve in this issue.

Account settings > Profile > Address: set a US address, switch Country to United Kingdom, type anything in the State field, Save; then switch Country back to United States and Save without touching State. Expected: the State field is cleared when switching back to the US, and saving with an empty/invalid state shows an inline "State is invalid" error. Actual: the stale UK-typed state value survives the country switch, passes client validation, and the server rejection surfaces as a generic "Oops something went wrong" error in the verification code flow.

What is the root cause of that problem?

In src/components/AddressForm.tsx, the Country selector's onValueChange goes straight to onAddressChanged - nothing clears the state field when the country changes. The state field is free-text for non-US countries and a dropdown (StateSelector) for the US, but both write to the same INPUT_IDS.STATE value. Validation only checks presence: if (values.country === CONST.COUNTRY.US && !values.state) errors.state = ... (the "Check State dropdown is a valid state" block) - a stale non-empty UK value is truthy, so it passes. The server then rejects the invalid US state and the generic API error is what the user sees.

What changes do you think we should make in order to solve the problem?

  1. In AddressForm, intercept the country change: when INPUT_IDS.COUNTRY changes via onAddressChanged, reset INPUT_IDS.STATE to '' (clear the draft state), so a state value typed for one country can never be submitted for another. This matches the issue's expected result (State field empty after switching back to the US).
  2. Keep the existing US presence check; with the reset in place, saving without picking a state correctly produces the inline "State is invalid" error.
  3. Add a unit test for the address form validation: country US -> UK (type state) -> US clears the state value.

What alternative solutions did you explore?

Validating the state value against the US states list for US addresses would also catch the stale value, but it leaves the confusing UX of a UK-typed value sitting in the US dropdown; clearing on country change fixes the root (stale cross-country value) rather than the symptom.

I will verify: the exact repro steps (US -> UK -> type state -> Save -> US -> Save - State empty, inline state error on save); normal US flow (pick state from dropdown, save - works); non-US flow (free-text state, save - works); the new unit test passes.

khizzcr7 avatar Oct 22 '26 18:10 khizzcr7

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0139ed4098bdc50182

Proposal

Please re-state the problem that we are trying to solve in this issue.

In Account settings → Profile → Address, if a user switches Country from the US to a non-US country (e.g., United Kingdom), enters a non-US free-text state (e.g., "London"), and then switches Country back to United States and clicks Save without picking a US state:

  • The State selector visually appears empty,
  • Clicking Save bypasses client-side validation on the State field, enters the magic-code verification flow, and displays a generic backend error ("Oops something went wrong...") instead of showing an inline required/invalid error on the State field.

What is the root cause of that problem?

  1. Stale non-US state retained on country switch to US (src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx:411-416 & :44-50): When newCountry === CONST.COUNTRY.US, handleAddressChange calls resolveStateCode(selectedState):
    function resolveStateCode(stateValue: string): string {
        if (!stateValue || stateValue in STATES) {
            return stateValue;
        }
        const matchedCode = Object.keys(STATES).find((code) => translate(`allStates.${code as State}.stateName`).toLowerCase() === stateValue.trim().toLowerCase());
        return matchedCode ?? stateValue;
    }
    
    Because resolveStateCode falls back to ?? stateValue when no US state matches, switching back to the US leaves selectedState (and the form's state value) set to "London".
  2. Visual mismatch in StateSelector (src/components/StateSelector.tsx:76): StateSelector only renders a title if value in CONST.STATES. Because "London" is not in CONST.STATES, the picker renders blank (''), making the field look empty to the user even though the form value is "London".
  3. Incomplete US state validation (src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx:154-158 & src/components/AddressForm.tsx): Client-side validation only checks if (values.country === CONST.COUNTRY.US && !values.state) rather than verifying !(values.state in CONST.STATES). Thus "London" passes validation and is submitted to the backend.

What changes do you think we should make in order to solve the problem?

  1. Return '' from resolveStateCode when no US state matches (src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx:44-50) and sync the form draft:
function resolveStateCode(stateValue: string): string {
    if (!stateValue || stateValue in STATES) {
        return stateValue;
    }
    const matchedCode = Object.keys(STATES).find(
        (code) => translate(`allStates.${code as State}.stateName`).toLowerCase() === stateValue.trim().toLowerCase(),
    );
    return matchedCode ?? '';
}

And when newCountry === CONST.COUNTRY.US in handleAddressChange (PrivatePersonalDetailsPage.tsx:411-416), update both setSelectedState(resolved) and FormActions.setDraftValues(ONYXKEYS.FORMS.PRIVATE_PERSONAL_DETAILS_FORM, {state: resolved}) when resolved !== selectedState.

  1. Validate that US state values belong to CONST.STATES (PrivatePersonalDetailsPage.tsx:154 & AddressForm.tsx):
if (values.country === CONST.COUNTRY.US && (!values.state || !(values.state in CONST.STATES))) {
    errors.state = translate('common.error.fieldRequired');
}

This guarantees that switching back to the United States clears any non-US free-text state and that saving without selecting a valid US state immediately highlights the State field with the required field error before entering the verification code flow.

bonnhatnguyen avatar Oct 24 '26 11:10 bonnhatnguyen

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Oct 24 '26 11:10 melvin-bot[bot]

Proposal

Please re-state the problem that we are trying to solve in this issue.

In Account > Profile > Address (PrivatePersonalDetailsPage), if a user enters or previously saved a non-US address with a free-text state (e.g., Country = UK, State = test), and then changes Country to United States:

  1. The State dropdown (StateSelector) visually appears blank/empty because test is not a valid US state code.
  2. However, clicking Save without selecting a US state passes client-side validation and opens the magic code verification modal.
  3. Entering the verification code then fails with a generic backend error instead of highlighting the State field as required before leaving the form.

What is the root cause of that problem?

There are three bugs in src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx:

  1. resolveStateCode falls back to returning the raw non-US stateValue when no US state matches (PrivatePersonalDetailsPage.tsx#L43-L49):

    function resolveStateCode(stateValue: string): string {
        if (!stateValue || stateValue in COMMON_CONST.STATES) {
            return stateValue;
        }
        const match = Object.entries(COMMON_CONST.STATES).find(([, v]) => v.stateName.toLowerCase() === stateValue.toLowerCase());
        return match ? match[0] : stateValue;
    }
    

    When stateValue is "test" (a non-US state), resolveStateCode("test") returns "test".

  2. Switching Country to United States retains the invalid non-US state in selectedState and form draft values (PrivatePersonalDetailsPage.tsx#L369-L375):

    if (newCountry === CONST.COUNTRY.US) {
        const resolved = resolveStateCode(selectedState);
        if (resolved !== selectedState) {
            setSelectedState(resolved);
        }
        return;
    }
    

    Whereas switching to a non-US country clears selectedState and calls setDraftValues(ONYXKEYS.FORMS.PERSONAL_DETAILS_FORM, {[INPUT_IDS.STATE]: ''}) (#L377-L379), switching to CONST.COUNTRY.US leaves selectedState (and InputWrapper's value={selectedState as State}) as "test". In src/components/StateSelector.tsx#L76, StateSelector computes:

    const title = stateCode && stateCode in COMMON_CONST.STATES ? translate(`allStates.${stateCode}.stateName`) : '';
    

    So StateSelector renders an empty title ('') on screen while its underlying form value in FormProvider is still "test".

  3. validate does not verify that stateValue is a valid US state code when effectiveCountry === CONST.COUNTRY.US (PrivatePersonalDetailsPage.tsx#L149-L153):

    const stateValue = values[INPUT_IDS.STATE] ?? '';
    const effectiveCountry = values[INPUT_IDS.COUNTRY] ?? '';
    if (!stateValue.trim()) {
        errors[INPUT_IDS.STATE] = translate('common.error.fieldRequired');
    }
    

    Because stateValue is "test", !stateValue.trim() is false, so client-side validation succeeds and opens the validate-code action modal.

What changes do you think we should make in order to solve the problem?

In src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx:

  1. Update resolveStateCode (#L43-L49) so that when resolving for US, non-matching state strings return '' (and only normalize on mount when the country is US):

    function resolveUSStateCode(stateValue: string): string {
        if (!stateValue) {
            return '';
        }
        if (stateValue in COMMON_CONST.STATES) {
            return stateValue;
        }
        const match = Object.entries(COMMON_CONST.STATES).find(([, v]) => v.stateName.toLowerCase() === stateValue.toLowerCase());
        return match ? match[0] : '';
    }
    

    And on mount (#L76-L83):

    const draftCountry = draftValues?.[INPUT_IDS.COUNTRY] ?? '';
    const draftState = draftValues?.[INPUT_IDS.STATE] ?? '';
    const initialCountry = draftCountry || country || ((defaultCountry as Country | undefined) ?? '');
    const rawInitialState = draftState || state;
    const initialState = initialCountry === CONST.COUNTRY.US ? resolveUSStateCode(rawInitialState) : rawInitialState;
    const [selectedCountry, setSelectedCountry] = useState<Country | ''>(initialCountry);
    const [selectedState, setSelectedState] = useState(initialState);
    
  2. Clear or resolve selectedState and the form draft value when switching Country to CONST.COUNTRY.US (#L369-L375):

    if (newCountry === CONST.COUNTRY.US) {
        const resolved = resolveUSStateCode(selectedState);
        setSelectedState(resolved);
        setDraftValues(ONYXKEYS.FORMS.PERSONAL_DETAILS_FORM, {[INPUT_IDS.STATE]: resolved});
        return;
    }
    
  3. Validate in validate (#L149-L153) that US addresses have a valid state code in COMMON_CONST.STATES:

    const stateValue = values[INPUT_IDS.STATE] ?? '';
    const effectiveCountry = values[INPUT_IDS.COUNTRY] ?? '';
    if (!stateValue.trim() || (effectiveCountry === CONST.COUNTRY.US && !(stateValue in COMMON_CONST.STATES))) {
        errors[INPUT_IDS.STATE] = translate('common.error.fieldRequired');
    }
    

What alternative solutions did you explore? (Optional)

  • Only adding the check in validate without clearing selectedState / draftValues when switching Country to US: If selectedState remained "test", clicking the StateSelector row would pass state=test as a route param to DYNAMIC_ROUTES.ADDRESS_STATE.getRoute(stateCode, label) (src/components/StateSelector.tsx#L91). Resolving to '' on country change AND validating stateValue in COMMON_CONST.STATES in validate keeps both the UI state and form validation completely consistent.

xian96xx avatar Oct 25 '26 14:10 xian96xx

📣 @xian96xx! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

melvin-bot[bot] avatar Oct 25 '26 14:10 melvin-bot[bot]

@situchan Whoops! This issue is 2 days overdue. Let's get this updated quick!

melvin-bot[bot] avatar Oct 28 '26 21:10 melvin-bot[bot]

@situchan Eep! 4 days overdue now. Issues have feelings too...

melvin-bot[bot] avatar Oct 30 '26 21:10 melvin-bot[bot]

@situchan Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!

melvin-bot[bot] avatar Nov 03 '26 23:11 melvin-bot[bot]

@situchan Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!

melvin-bot[bot] avatar Nov 04 '26 02:11 melvin-bot[bot]

@situchan 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

melvin-bot[bot] avatar Nov 04 '26 03:11 melvin-bot[bot]

@MelvinBot implement your proposal for testing

situchan avatar Nov 04 '26 21:11 situchan

🤖 Web test steps verification results: ✅ pass

Verified on dev NewDot web: London clears when switching UK → US, Save shows an inline State error without verification navigation, and selecting New York clears that error. Other required basic details were empty, so State was not the sole submission blocker.

New York selected and State error cleared
Step Status
1. Open Profile → AddressOpened Home address; Personal details appeared.
✅
2. Select a US addressRead-back confirmed a US address with New York selected.
✅
3. Change Country to United KingdomUnited Kingdom appeared with an editable State / Province field.
✅
4. Enter London and SaveLondon appeared. Save remained on Personal details with postcode and missing basic-details errors.
✅
5. Change Country back to United StatesState was empty; London was cleared.
✅
6. Save without selecting StateState showed “This field is required.” No verification page opened; other required fields also blocked submission.
Empty US State with inline required error after Save
✅
7. Select a valid US stateNew York appeared and the State error cleared.
New York selected and State error cleared
✅

Implemented in Clear invalid US profile states before verification, a draft assigned to situchan. Ten regression tests, lint, typecheck, and Storybook passed. Full Jest timed out; wrapper and formatting checks remain incomplete. Mark the draft ready for review when your testing is complete.


view run · no recording available

MelvinBot avatar Nov 04 '26 22:11 MelvinBot

@situchan 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[bot] avatar Nov 05 '26 21:11 melvin-bot[bot]