Skip to content

[HOLD for payment 2023-10-10] [$500] Web - Country and State fields are empty if accessed via deep link #27814

Closed

Description

@kbecciv

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. Open App -> Navigate to Settings -> Profile -> Personal Details -> Home address
  2. Enter Address details > Save the updated address
  3. Copy address URL (https://staging.new.expensify.com/settings/profile/personal-details/address)
  4. Sign Out
  5. Paste URL and hit enter
  6. Login with your credentials
  7. Home address page opens but "Country" and "State" values are missing

Expected Result:

"Country" and "State/Province" values should be shown if saved by user

Actual Result:

"Country" and "State/Province" values are missing given that user's saved the values

Workaround:

Unknown

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.70.7
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

country_state_value_missing.mov
Recording.4612.mp4

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

View all open jobs on GitHub

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 19, 2023
  2. melvin-bot commented on Sep 19, 2023

    @melvin-bot
  3. changed the title [-]Web - Country and State fields are empty if accessed via deep link[/-] [+][$500] Web - Country and State fields are empty if accessed via deep link[/+] on Sep 19, 2023
  4. melvin-bot commented on Sep 19, 2023

    @melvin-bot

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

  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Sep 19, 2023
  6. melvin-bot commented on Sep 19, 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
  7. melvin-bot commented on Sep 19, 2023

    @melvin-bot

    Triggered auto assignment to @Christinadobrzyn (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

  8. melvin-bot commented on Sep 19, 2023

    @melvin-bot

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

  9. saranshbalyan-1234 commented on Sep 19, 2023

    @saranshbalyan-1234
    Contributor

    Proposal

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

    "Country" and "State/Province" values are missing while using deeplink

    What is the root cause of that problem?

    const address = lodashGet(privatePersonalDetails, 'address') || {};

    The address object is initially empty, which is causing the issue as we are not setting the state and country states once the address object is changed.
    const [state, setState] = useState(address.state);

    const [currentCountry, setCurrentCountry] = useState(PersonalDetails.getCountryISO(lodashGet(privatePersonalDetails, 'address.country')));

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

        useEffect(() => {
          setState(address.state)
          setCurrentCountry(address.country)
        }, [address]);
        

    Also we can move country state from

    const [currentCountry, setCurrentCountry] = useState(PersonalDetails.getCountryISO(lodashGet(privatePersonalDetails, 'address.country')));

    to this

        const [currentCountry, setCurrentCountry] = useState(PersonalDetails.getCountryISO(address.country));

    What alternative solutions did you explore? (Optional)

    N/A

  10. lcsvcn commented on Sep 19, 2023

    @lcsvcn

    Proposal

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

    Country and State fields are empty if accessed via deep link

    What is the root cause of that problem?

    The issue arises from the fact that the address.state and address.country values are being fetched after the initial state initialization. This delay in fetching the values is due to the presence of an isLoading variable. Consequently, when the initial state is set, it is based on an empty JSON object because the actual values have not yet been retrieved. This results in incorrect initialization with empty values, which should ideally reflect the user's address information.

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

    I recommend initializing all fields (such as state, country, firstStreet, and secondStreet) with empty values initially. Then, use the useEffect hook to update these fields only when the isLoadingPersonalDetails variable indicates that the data retrieval process has completed.

    Please note that both of these lines in the code:

    const [currentCountry, setCurrentCountry] = useState(PersonalDetails.getCountryISO(lodashGet(privatePersonalDetails, 'address.country')));

    const [state, setState] = useState(address.state);

    Are unnecessary, as they set values when the address data is still loading.

    This approach simplifies the code and ensures that we always work with the most up-to-date values.

    At src/pages/settings/Profile/PersonalDetails/AddressPage.js:

        const address = lodashGet(privatePersonalDetails, 'address') || {};
        const isLoadingPersonalDetails = lodashGet(privatePersonalDetails, 'isLoading', true);
    
        const [state, setState] = useState('');
        const [country, setCountry] = useState('');
        const [firstStreet, setFirstStreet] = useState('');
        const [secondStreet, setSecondStreet] = useState('');
        
        useEffect(() => {
           if(isLoadingPersonalDetails === true) { 
                return;
            }
            
            const street =  (address.street || '').split('\n');
            
            setState(address.state);
            setCountry(address.country);
            setFirstStreet(street[0]);
            setFirstStreet(street[1]);
        }, [address, isLoadingPersonalDetails]);
    
    

    We can keep the street1, street2 as it is in the line:

    const [street1, street2] = (address.street || '').split('\n');

    Because they currently aren't using setState. I would suggest changing to the setState, even tho we are not changing theirs states, and use in the useEffect to avoid future bugs similar to this, because street1 and street2 are using outdated values. But that part is optional, since it work fine without changing them, so that part is completely optional and up to the review to see if they agree with the modification or not. If we would not change we just change the state and country part of the implementation that I suggested.

    This is a video working locally with the changes that I mention above.

    Video
    video.bug.mov

    Here are my suggested changes for review

    If my proposal is accepted, I can open a PR in a few hours to fix this. Thank you!

    What alternative solutions did you explore? (Optional)

    N/A

  11. 42 remaining items

  12. saranshbalyan-1234 commented on Oct 3, 2023

    @saranshbalyan-1234
    Contributor

    Thanks for explaining :)

  13. Christinadobrzyn commented on Oct 10, 2023

    @Christinadobrzyn
    Contributor

    Payouts due after we get the checklist done:

    Issue Reporter: $50 @ufumerfarooq (Paid in Upwork)
    Contributor: $500 + $250 bonus @saranshbalyan-1234 (Paid in Upwork)
    Contributor+: $500 + $250 bonus @eVoloshchak (paid outside Upwork

    Eligible for 50% #urgency bonus? Y - based on #27814 (comment)

    Upwork job is here.

    @eVoloshchak can you complete the checklist for us?

  14. umerfarooq492 commented on Oct 10, 2023

    @umerfarooq492

    @Christinadobrzyn can you please guide me on how the payouts work for reporters? From past issues, it seems like some reporters get 50 and some get 250 and 500

  15. saranshbalyan-1234 commented on Oct 10, 2023

    @saranshbalyan-1234
    Contributor

    applied @Christinadobrzyn please check

  16. Christinadobrzyn commented on Oct 10, 2023

    @Christinadobrzyn
    Contributor

    @ufumerfarooq Happy to clarify. We recently changed our payments:

    • Any GHs created after Aug 30th - the reporter gets $50
    • Any GHs created before Aug 30th - the reporter received $250 (old pricing and there are still some open GHs before Aug 30th)
    • If a contributor is also the reporter, the contributor will be paid as the reporter and also as the contributor (so $50 + $500, etc).
  17. Christinadobrzyn commented on Oct 10, 2023

    @Christinadobrzyn
    Contributor

    @saranshbalyan-1234 I think you'll see an offer now, I'll hire you for the $500 and include the $250 bonus (so the payment will be $750 but the breakdown on the offer will be different).

  18. Christinadobrzyn commented on Oct 10, 2023

    @Christinadobrzyn
    Contributor

    @eVoloshchak can you complete the #27814 (comment) for us? Thanks!

  19. saranshbalyan-1234 commented on Oct 10, 2023

    @saranshbalyan-1234
    Contributor
  20. eVoloshchak commented on Oct 12, 2023

    @eVoloshchak
    Contributor
    • The PR that introduced the bug has been identified. Link to the PR: there isn't a PR that caused this bug, it was present in the initial implementation
    • 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: N/A
    • 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: I don't think an additional discussion is needed, this is a case that was missed during the initial implementation. We already have a reviewer checklist item precisely for these types of bugs: 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.
  21. eVoloshchak commented on Oct 12, 2023

    @eVoloshchak
    Contributor

    Regression Test Proposal

    1. Go to Settings -> Profile -> Personal Details -> Home address
    2. Fill out all the details
    3. Log out
    4. Open https://staging.new.expensify.com/settings/profile/personal-details/address
    5. Log in and verify that state and country fields are populated

    Do we agree 👍 or 👎

  22. JmillsExpensify commented on Oct 12, 2023

    @JmillsExpensify
    Contributor

    $750 payment approved for @eVoloshchak based on the BZ summary.

  23. Christinadobrzyn commented on Oct 12, 2023

    @Christinadobrzyn
    Contributor

    regression test here - https://github.com/Expensify/Expensify/issues/325802

    Payment is complete - based on - #27814 (comment)

    Closing!

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions