Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOLD for payment 2023-10-09] [$500] Android - State gets cleared when selecting the same country #28034

Closed
6 tasks
kbecciv opened this issue Sep 22, 2023 · 32 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@kbecciv
Copy link

kbecciv commented Sep 22, 2023

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:

Action Performed:

  1. Open settings > profile > personal-details > address
  2. Click on country & select India, enter any state name manually and save.
  3. Now click on country and select the India again.
  4. Observe the saved state gets cleared

Expected Result:

The state should not get cleared.

Actual Result:

The state gets cleared.

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

WhatsApp.Video.2023-09-19.at.17.19.38.mp4
Screen_Recording_20230922_122921_New.Expensify.mp4

Expensify/Expensify Issue URL:
Issue reported by: krishna2323
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1695225387907579

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0182f7137fd1deb9ae
  • Upwork Job ID: 1705259279037448192
  • Last Price Increase: 2023-09-22
  • Automatic offers:
    • dukenv0307 | Contributor | 26875340
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

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

@kbecciv kbecciv added the External Added to denote the issue can be worked on by a contributor label Sep 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

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

@melvin-bot melvin-bot bot changed the title Android - State gets cleared when selecting the same country [$500] Android - State gets cleared when selecting the same country Sep 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

Current assignee @trjExpensify is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

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

@kbecciv
Copy link
Author

kbecciv commented Sep 22, 2023

Proposal by: krishna2323
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1695225387907579

Proposal

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

App clears state even if the selected country is not changed.

What is the root cause of that problem?

We are not checking if the selected country is the changed or not before updating state to empty string.

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

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

We should return from the function if the key is country and value is same as the currentCountry.

if (key === 'country' && currentCountry === value) return;

Result

@dukenv0307
Copy link
Contributor

dukenv0307 commented Sep 22, 2023

Proposal

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

The state gets cleared when selecting the same country in CountryPicker.

What is the root cause of that problem?

In here, the CountryPicker is calling onInputChange even though the input did not change, thus triggering the address update here, clearing the state.

CountryPicker is a component inside the Form, so it should only trigger onInputChange when the value actually changes.

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

Update here to check if the country changes first before calling onInputChange. The same issue happens for the StatePicker, we need to fix there as well.

We have to fix it inside CountryPicker rather than in AddressPage because:

  • if we call onInputChange from Form element even when it's not changed, it will set wrong Form state, and causing unintended side effects, for example here it will set the input to touched, even though the input was not touched yet (unchanged), it can trigger validation out of nowhere as well.
  • to be consistent with other Form elements which only triggers the change when things actually changes.
  • avoid redundant state update in the form
  • also make sure we don't face the issue in anther place that reuses the CountryPicker/StatePicker

What alternative solutions did you explore? (Optional)

NA

@melvin-bot
Copy link

melvin-bot bot commented Sep 23, 2023

📣 @devharp! 📣
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
Copy link

melvin-bot bot commented Sep 23, 2023

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

@devharp
Copy link

devharp commented Sep 23, 2023

Contributor details
Your Expensify account email: hsingh.161297@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01ae4662188c69bef7

Proposal for Addressing TextInput State Clearance Issue

Problem Statement

The issue at hand is related to the inadvertent clearing of the 'state' when selecting the same country in the CountryPicker.

Root Cause

The root cause of this issue can be attributed to the CountryPicker component. Specifically, the onInputChange function in the CountryPicker is triggered even when the same country is selected, inadvertently triggering the address update and causing the state to be cleared.

Proposed Solution

To resolve this issue, we propose a modification to the CountryPicker component. The proposed changes involve verifying if the new country is selected onInputChange.

Reasons for Modifying CountryPicker

Preserving Form State Integrity: By invoking onInputChange selectively, only when the value changes, we can maintain the correct form states, preventing unintended side effects and preserving form state integrity.

Consistency and Efficiency: This adjustment ensures consistency with other form elements, following the principle of triggering change events only when necessary and avoiding redundant state updates in the form.

Enhanced Reusability: Modifying CountryPicker ensures the resolution of this issue across the application, promoting reusability without encountering similar problems elsewhere.

@melvin-bot
Copy link

melvin-bot bot commented Sep 23, 2023

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

@trjExpensify
Copy link
Contributor

Is this perhaps linked? #27814

@eVoloshchak
Copy link
Contributor

@trjExpensify, the root cause for this is different, but the issues are similar
This was actually proposed as an enhancement in one of the proposals for #27814 (comment), before this issue was even created

I think the city field also should be clear after changing country like state field. This is BUG 2

I assumed this was by design, but clearly it's not.

I see where you're coming from, but I believe this is by design. We don't clear anything besides state when changing a country, it's not necessarily linear, you can populate all of the fields in any order

In my opinion, we should keep the issues separate, those are two different bugs that happen on the same page

@burczu
Copy link
Contributor

burczu commented Sep 25, 2023

I've just reviewed all the proposals and I think we should proceed with the one from @dukenv0307 - while the solution from @Krishna2323 would also fix the issue I agree with @dukenv0307's reasoning why it's better to fix it inside the CountryPicker component.

The proposal from @devharp is actually the same as the one from @dukenv0307 but it was posted later.

🎀 👀 🎀 C+ reviewed

@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

Triggered auto assignment to @arosiclair, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 26, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 26, 2023

📣 @dukenv0307 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Sep 26, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 2, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.75-12 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-10-09. 🎊

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

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:

  • [@burczu] The PR that introduced the bug has been identified. Link to the PR:
  • [@burczu] 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:
  • [@burczu] 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:
  • [@burczu] Determine if we should create a regression test for this bug.
  • [@burczu] 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.
  • [@trjExpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 Daily KSv2 labels Oct 9, 2023
@trjExpensify
Copy link
Contributor

👋 Can we get this checklist filled out to proceed with payment please?

@melvin-bot melvin-bot bot added the Overdue label Oct 13, 2023
@trjExpensify
Copy link
Contributor

Bump!

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Oct 13, 2023
@trjExpensify
Copy link
Contributor

Same as Friday, Melv!

@melvin-bot melvin-bot bot removed the Overdue label Oct 16, 2023
@burczu
Copy link
Contributor

burczu commented Oct 17, 2023

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:

  • [@burczu] The PR that introduced the bug has been identified. Link to the PR: No regression - it worked this way from the beginning.
  • [@burczu] 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
  • [@burczu] 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: n/a
  • [@burczu] Determine if we should create a regression test for this bug.
  • [@burczu] 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.
  • [@trjExpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@trjExpensify
Copy link
Contributor

👋 Mind adding a bit of reasoning on the justification for these, please?

@burczu] Determine if we should create a regression test for this bug.
[@burczu] 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.

@melvin-bot melvin-bot bot added the Overdue label Oct 20, 2023
@arosiclair
Copy link
Contributor

Bump @burczu ^

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Oct 20, 2023
@trjExpensify
Copy link
Contributor

No change. :)

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Oct 23, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 27, 2023

@arosiclair, @burczu, @trjExpensify, @dukenv0307 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@burczu
Copy link
Contributor

burczu commented Oct 30, 2023

@trjExpensify In terms of justification for not adding regression tests - I think this bug wasn't impactful and does not brake important flow of the application. It was just slightly inconvenient for the end user that they had to re-enter the state after selecting the same country from the country selector, so it's more like UX fix. What do you think?

@melvin-bot melvin-bot bot removed the Overdue label Oct 30, 2023
@trjExpensify
Copy link
Contributor

Cool, thanks for expanding. I can see that argument because it's reselecting the same country which is probably not that likely to happen.

Alright, so with that out of the way, moving on to payments:

Urgency bonus applied as per here and the PR pre-dating the change.

@trjExpensify
Copy link
Contributor

Settled up with @Krishna2323. Closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

7 participants