Skip to content

[C+ Checklist Needs Completion] [$1000] The State filled is not cleared after selecting another country #23839

Closed

Description

@kavimuru

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Go profile > Personal detail > Home Address Page
  2. Click on State and choose any state
  3. Now click on Country and select a country other than the United States.
    Notice that the state filled shows an abbreviation of the previously selected State

Expected Result:

The State filled is cleared

Actual Result:

The State filled is not cleared. Shows abbreviation of previously selected State

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.47-3
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

Test92.Stateabrrivation-1.mp4
Recording.1400.mp4

Expensify/Expensify Issue URL:
Issue reported by: @daveSeife
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1690482380069389

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01f0fbcbd5a20b5cfa
  • Upwork Job ID: 1686035992494268416
  • Last Price Increase: 2023-07-31
  • Automatic offers:
    • daveSeife | Reporter | 25899761
    • dukenv0307 | Contributor | 25996636

Activity

  1. added
    Daily
    Bug
    on Jul 28, 2023
  2. melvin-bot commented on Jul 28, 2023

    @melvin-bot

    Triggered auto assignment to @greg-schroeder (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  3. melvin-bot commented on Jul 28, 2023

    @melvin-bot

    Bug0 Triage Checklist (Main S/O)

    • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
    • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
      • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
    • This bug is reproducible using the reproduction steps in the OP. S/O
      • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
      • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
    • This issue is filled out as thoroughly and clearly as possible
      • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
    • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
  4. jeet-dhandha commented on Jul 29, 2023

    @jeet-dhandha
    Contributor

    Proposal

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

    • Currently we are selecting State first (when default Country is US) and then selecting other Country lets say India, then State is not getting empty.

    What is the root cause of that problem?

    • We are not resetting the state input in form when we are changing the country input.
    • Also even if we update the state component from Picker to TextInput the form's value won't get updated.
    • Hence showing the previous selected state.

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

    • We can implement a custom formRef which acts like a ref as the below object and it changes values when inputValues or inputRefs changes in Form component:
    {  resetField: (inputID) => {... reset the input field} }
    
    • We can use this ref in handleAddressChange function of AddressPage component to reset the State input field.
    Form.js Code Reference
    useEffect(() => {
        props.formRef({
            resetField: (inputID) => {
                if (!inputRefs.current[inputID] || !inputValues[inputID]) return;
                setInputValues((prevState) => ({...prevState, [inputID]: ''}));
            },
        });
    }, [inputRefs, props.formRef, inputValues]);
    When using `Form` in AddressPage.js
    const handleAddressChange = (value, key) => {
            if (key !== 'country') {
                return;
            }
    +       if (value !== currentCountry && formRef.current && formRef.current.resetField) {
    +           formRef.current.resetField('state');
    +       }
            setCurrentCountry(value);
        };
    ...rest code
    
    <Form ...rest
    +  formRef={(ref) => formRef.current = ref}
    >
    

    What alternative solutions did you explore? (Optional)

    • N/A
  5. dukenv0307 commented on Jul 29, 2023

    @dukenv0307
    Contributor

    Proposal

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

    The State filled is not cleared after selecting another country

    What is the root cause of that problem?

    We handle the change of country in handleAddressChange here and we only change the country, not clear state

    const handleAddressChange = (value, key) => {
    if (key !== 'country') {
    return;
    }
    setCurrentCountry(value);

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

    1. We can create a state to control state the same as country
    const [state, setState] = useState(address.state);
    
    1. Add onValueChange={handleAddressChange} into StatePicker and TextInput



    3. Change the default value here to state

    defaultValue={address.state || ''}

    1. change defaultValue prop of TextInput to value

    2. In handleAddressChange we check if the key is country we will reset the state and if the key is state we set value to it state

    const handleAddressChange = (value, key) => {
        if (key !== 'country' && key !== 'state') {
            return;
        }
        if (key === 'country') {
            setCurrentCountry(value);
            setState('');
            return;
        }
        setState(value);
    };
    

    What alternative solutions did you explore? (Optional)

  6. greg-schroeder commented on Jul 31, 2023

    @greg-schroeder
    Contributor

    Reproduced. Agreed that the state field should just be cleared

  7. added
    External
    on Jul 31, 2023
  8. changed the title [-] The State filled is not cleared after selecting another country[/-] [+][$1000] The State filled is not cleared after selecting another country[/+] on Jul 31, 2023
  9. melvin-bot commented on Jul 31, 2023

    @melvin-bot
  10. added
    Help Wanted
    on Jul 31, 2023
  11. melvin-bot commented on Jul 31, 2023

    @melvin-bot

    Current assignee @greg-schroeder is eligible for the External assigner, not assigning anyone new.

  12. 40 remaining items

  13. changed the title [-][$1000] The State filled is not cleared after selecting another country[/-] [+][HOLD for payment 2023-08-17] [$1000] The State filled is not cleared after selecting another country[/+] on Aug 10, 2023
  14. removed
    Reviewing
    on Aug 10, 2023
  15. melvin-bot commented on Aug 10, 2023

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  16. melvin-bot commented on Aug 10, 2023

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.52-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2023-08-17. 🎊

    After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

    • External issue reporter
    • Contributor that fixed the issue
    • Contributor+ that helped on the issue and/or PR

    For reference, here are some details about the assignees on this issue:

    As a reminder, here are the bonuses/penalties that should be applied for any External issue:

    • Merged PR within 3 business days of assignment - 50% bonus
    • Merged PR more than 9 business days after assignment - 50% penalty
  17. melvin-bot commented on Aug 10, 2023

    @melvin-bot

    BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

    • [@allroundexperts] The PR that introduced the bug has been identified. Link to the PR:
    • [@allroundexperts] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
    • [@allroundexperts] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
    • [@allroundexperts] Determine if we should create a regression test for this bug.
    • [@allroundexperts] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
    • [@greg-schroeder] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  18. greg-schroeder commented on Aug 17, 2023

    @greg-schroeder
    Contributor

    Issue Participants:

    Issue reported by: @daveSeife
    Contributor: @dukenv0307
    C+: @allroundexperts

    Was this issue merged in time to be eligible for the speed bonus? Yes
    Were their any regressions? ❌

    Payment summary:

    Reporter: $250
    Contributor: $1,500 ($500 bonus)
    C+: $1,500 ($500 bonus)

  19. greg-schroeder commented on Aug 17, 2023

    @greg-schroeder
    Contributor

    Please request payment via NewDot @allroundexperts - all that's left here is taking care of the checklist!

  20. removed
    Awaiting Payment
    on Aug 17, 2023
  21. changed the title [-][HOLD for payment 2023-08-17] [$1000] The State filled is not cleared after selecting another country[/-] [+][HOLD for checklist] [$1000] The State filled is not cleared after selecting another country[/+] on Aug 17, 2023
  22. changed the title [-][HOLD for checklist] [$1000] The State filled is not cleared after selecting another country[/-] [+][C+ Checklist Needs Completion] [$1000] The State filled is not cleared after selecting another country[/+] on Aug 17, 2023
  23. allroundexperts commented on Aug 17, 2023

    @allroundexperts
    Contributor

    Requested payment in ND. Onto the checklist!

  24. allroundexperts commented on Aug 20, 2023

    @allroundexperts
    Contributor

    Checklist

    1. PR which introduced this: 17548 Personal details push to page #21049
    2. Comment on the PR: https://github.com/Expensify/App/pull/21049/files#r1299446609
    3. I think a slack discussion is not needed here because this was a edge case which could have been caught only by doing rigorous QA.
    4. A regression test might be helpful here.
    5. The test steps given in the issue description look good enough to me.
  25. greg-schroeder commented on Aug 24, 2023

    @greg-schroeder
    Contributor

    Filing regression test and closing!

  26. JmillsExpensify commented on Aug 24, 2023

    @JmillsExpensify
    Contributor

    Reviewed the details for @allroundexperts. $1,500 approved for payment in NewDot based on BZ summary above.

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

Metadata

Metadata

Labels

BugExternalWeekly

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions