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

[C+ Checklist Needs Completion] [$250] Profile - Address disappears when filling date of birth #45197

Closed
1 of 6 tasks
lanitochka17 opened this issue Jul 10, 2024 · 36 comments
Closed
1 of 6 tasks
Assignees
Labels
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

@lanitochka17
Copy link

lanitochka17 commented Jul 10, 2024

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.0.6-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: https://expensify.testrail.io/index.php?/tests/view/4706283
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.chat.expensify.com
  2. Go to Account Setting > Profile
  3. Go Address > fill the address and save
  4. Go to date of birth > Fill the date and save

Expected Result:

Both Address and Date of birth are displayed in the Personal detail page

Actual Result:

The address is not shown on the personal detail page after editing Date of birth

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6538125_1720630431120.Issue_Address_Disappears.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~012627cfecde429dc3
  • Upwork Job ID: 1811457000867073269
  • Last Price Increase: 2024-07-11
Issue OwnerCurrent Issue Owner: @greg-schroeder
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 10, 2024
Copy link

melvin-bot bot commented Jul 10, 2024

Triggered auto assignment to @greg-schroeder (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@lanitochka17
Copy link
Author

@greg-schroeder FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

@abzokhattab
Copy link
Contributor

abzokhattab commented Jul 10, 2024

Proposal

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

Address disappears when filling date of birth

What is the root cause of that problem?

On changing the date, the backend return the address inside an addresses array, and doesn't return the address object

image

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

  1. either to return merge address into onyx as well, the same as happened with the update address command
  2. OR in the frontend we should check if the privatePersonalDetails.addressthen use it else check for privatePersonalDetails?.address?.[0] if found:
    for example here

we should change it to:

function getFormattedAddress(privatePersonalDetails: OnyxEntry<PrivatePersonalDetails>): string {
    const {address, addresses} = privatePersonalDetails ?? {};
    const addressToUse = (address ?? addresses?.[0]) as PrivatePersonalDetails['address'];
    const [street1, street2] = getStreetLines(addressToUse?.street);
    const formattedAddress =
        formatPiece(street1) +
        formatPiece(street2) +
        formatPiece(addressToUse?.city) +
        formatPiece(addressToUse?.state) +
        formatPiece(addressToUse?.zip) +
        formatPiece(addressToUse?.country);

    // Remove the last comma of the address
    return formattedAddress.trim().replace(/,$/, '');
}

we should update all other privatePersonalDetails.address to use privatePersonalDetails.addresses?.[0] as a fallback

alternatively

we can extract the address object from the privatePersonalDetails using:

const {addressCity,addressCountry,addressState,addressStreet,addressZip} = privatePersonalDetails

then construct the address object from these vars

Partial Result:

Screen.Recording.2024-07-10.at.10.16.19.PM.mov

alternatively

as arosiclair pointed out here we can remove the privatePersonalDetails.address completely ... to do that we should

  • change the optimistic data of the change address command to use the first object of the addresses array instead of the address object
  • updated all references that use privatePersonalDetails.address to use the last object of the addresses array instead

@greg-schroeder greg-schroeder added the External Added to denote the issue can be worked on by a contributor label Jul 11, 2024
Copy link

melvin-bot bot commented Jul 11, 2024

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

@melvin-bot melvin-bot bot changed the title Profile - Address disappears when filling date of birth [$250] Profile - Address disappears when filling date of birth Jul 11, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 11, 2024
Copy link

melvin-bot bot commented Jul 11, 2024

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

@arosiclair
Copy link
Contributor

I detailed the root of this problem here.

@abzokhattab you should remove address completely and use the last object in the addresses array as the current address.

@tienifr
Copy link
Contributor

tienifr commented Jul 12, 2024

Coming from #45339

Hi @arosiclair My proposal addresses the problem according to the right RCA and solution pointed out by you here

Proposal

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

The address is not shown on the personal detail page after editing Date of birth

What is the root cause of that problem?

As explained here, the back-end actually does not use address field, it has addresses instead where the last value is the one we should use. So when the back-end data returns, it will override the value in the input.

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

  1. Update here to use the correct address as last item from addresses
const addresses = privatePersonalDetails?.addresses ?? [];
const address = lodashLast(addresses);
  1. Update the optimistic data here so it will use append the address to addresses
addresses: [{
    street: PersonalDetailsUtils.getFormattedStreet(street, street2),
    city,
    state,
    zip,
    country,
}],

Or we can get the existing list of addresses from the Onyx data and append it. By passing privatePersonalDetails?.addresses to updateAddress here. Make it a new param of updateAddress and PersonalDetails.updateAddress, and append the newly address address accordingly

  1. In
    const address = useMemo(() => privatePersonalDetails?.address, [privatePersonalDetails]);
    , we also need to get the last address as using lodashLast as above.

Also needs to be updated in

const {address, legalFirstName, legalLastName, phoneNumber} = privatePersonalDetails ?? {};

And in

const {legalFirstName = '', legalLastName = '', phoneNumber = '', address: {city = '', country = '', state = '', street = '', zip = ''} = {}} = privatePersonalDetails;

And in https://github.com/Expensify/App/blob/main/src/pages/settings/Wallet/WalletPage/CardDetails.tsx#L19

...

We need to thoroughly check all usage of privatePersonalDetails and make sure to update the address being used (if any)

What alternative solutions did you explore? (Optional)

None

@tienifr
Copy link
Contributor

tienifr commented Jul 12, 2024

@arosiclair I also identified a lot more places that needs to be updated aside from what's identified here (point 3 in the proposal)

@abzokhattab
Copy link
Contributor

abzokhattab commented Jul 12, 2024

@abzokhattab you should remove address completely and use the last object in the addresses array as the current address.

@arosiclair Oh okay then, i updated the alternative proposal to remove the address completely
Thank you.

@NJ-2020
Copy link
Contributor

NJ-2020 commented Jul 14, 2024

Proposal

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

The address disappears when filling in the date of birth input

What is the root cause of that problem?

When we add an address to our personal info, we're setting the optimistic data in Onyx with the address property that doesn't exist in BE, and we display the address with the address property (optimistic data) that doesn't exist in BE.

So after we filled in our date of birth, it pulled new data from the BE i.e GetMissingOnyxMessages and the BE did not return the personal details with the address property, instead the BE returned with these properties:

image

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

We can use the address & addresses properties, and we still need to use the address property because it is optimistically updated first and shows faster without waiting response from BE, and use the addresses property if the first one is undefined and filtering if the current property is equal to true.

Screenshot 2024-07-14 125801

And I don't use the address{key} property for displaying the address information, because when we set an address input this property doesn't exist until I fill in the date of birth, and does not work well when the user has more than 1 street.

We can also use this logic when editing the address, because it also didn't work after filling in the date of birth input

const address = useMemo(() => privatePersonalDetails?.address, [privatePersonalDetails]);

Here's the code:

function getFormattedAddress(privatePersonalDetails: OnyxEntry<PrivatePersonalDetails>): string {
    const {address, addresses} = privatePersonalDetails ?? {};
    const userAddress = address ?? addresses?.filter((addr) => addr.current === true)[0];
    const [street1, street2] = getStreetLines(userAddress?.street);
    const formattedAddress =
        formatPiece(street1) + formatPiece(street2) + formatPiece(userAddress?.city) + formatPiece(userAddress?.state) + formatPiece(userAddress?.zip) + formatPiece(userAddress?.country);

    // Remove the last comma of the address
    return formattedAddress.trim().replace(/,$/, '');
}

I've tried and it's working very well

Result

2024-07-14.15-28-03.mp4

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Jul 14, 2024
@arosiclair
Copy link
Contributor

@mollfpr please review 🙇🏽‍♂️

Copy link

melvin-bot bot commented Jul 15, 2024

@arosiclair, @mollfpr, @greg-schroeder Whoops! This issue is 2 days overdue. Let's get this updated quick!

@greg-schroeder
Copy link
Contributor

Yup bump to @mollfpr for proposal review

@mollfpr
Copy link
Contributor

mollfpr commented Jul 17, 2024

Sorry for the delay 🙏

Reviewing it now!

@melvin-bot melvin-bot bot removed the Overdue label Jul 17, 2024
@mollfpr
Copy link
Contributor

mollfpr commented Jul 17, 2024

We can use the address & addresses properties, and we still need to use the address property because it is optimistically updated first and shows faster without waiting response from BE, and use the addresses property if the first one is undefined and filtering if the current property is equal to true.

@NJ-2020 I think we won't be use the address anymore.


We can go with @tienifr proposal since they will thoroughly update the usage of address. There will be a lot more detail that is easy to review in the PR.

@arosiclair Also, I see that the OpenApp API still return the address object. We will need to update that too.

Screenshot 2024-07-17 at 12 47 52

🎀 👀 🎀 C+ reviewed!

Copy link

melvin-bot bot commented Jul 17, 2024

Current assignee @arosiclair is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 17, 2024
Copy link

melvin-bot bot commented Jul 24, 2024

@arosiclair @mollfpr @greg-schroeder @tienifr 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!

@greg-schroeder
Copy link
Contributor

Do you have an update on this one @arosiclair?

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Jul 25, 2024
@tienifr
Copy link
Contributor

tienifr commented Jul 25, 2024

I don't think we need to hold for BE changes. PR ready for review #45751.

@arosiclair
Copy link
Contributor

Yeah no need to hold on those changes. They were deployed already last week though.

@greg-schroeder
Copy link
Contributor

Okay got it - PR is still being worked on

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Aug 6, 2024
@melvin-bot melvin-bot bot changed the title [$250] Profile - Address disappears when filling date of birth [HOLD for payment 2024-08-13] [$250] Profile - Address disappears when filling date of birth Aug 6, 2024
Copy link

melvin-bot bot commented Aug 6, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Aug 6, 2024
Copy link

melvin-bot bot commented Aug 6, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.16-8 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 2024-08-13. 🎊

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

  • @mollfpr requires payment through NewDot Manual Requests
  • @tienifr requires payment through NewDot Manual Requests

Copy link

melvin-bot bot commented Aug 6, 2024

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:

  • [@mollfpr] The PR that introduced the bug has been identified. Link to the PR:
  • [@mollfpr] 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:
  • [@mollfpr] 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:
  • [@mollfpr] Determine if we should create a regression test for this bug.
  • [@mollfpr] 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:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Aug 12, 2024
@greg-schroeder
Copy link
Contributor

Payment summary:

Contributor: @tienifr - $250 - ND manual request
C+: @mollfpr - $250 - ND manual request

cc @mollfpr can you complete the checklist so this can be closed out? Thanks!

@greg-schroeder greg-schroeder changed the title [HOLD for payment 2024-08-13] [$250] Profile - Address disappears when filling date of birth [C+ Checklist Needs Completion] [$250] Profile - Address disappears when filling date of birth Aug 13, 2024
@greg-schroeder greg-schroeder removed the Awaiting Payment Auto-added when associated PR is deployed to production label Aug 13, 2024
@mollfpr
Copy link
Contributor

mollfpr commented Aug 14, 2024

[@mollfpr] The PR that introduced the bug has been identified. Link to the PR:
[@mollfpr] 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:

No offending PR.

[@mollfpr] 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:

The regression step should be good.

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

  1. Go to Account Setting > Profile
  2. Go to Address > Fill in the address and save
  3. Go to the date of birth > Fill in the date and save
  4. Verify the address is saved
  5. 👍 or 👎

@melvin-bot melvin-bot bot added the Overdue label Aug 15, 2024
Copy link

melvin-bot bot commented Aug 16, 2024

@arosiclair, @mollfpr, @greg-schroeder, @tienifr Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@JmillsExpensify
Copy link

$250 approved for @mollfpr

Copy link

melvin-bot bot commented Aug 20, 2024

@arosiclair, @mollfpr, @greg-schroeder, @tienifr Still overdue 6 days?! Let's take care of this!

@greg-schroeder
Copy link
Contributor

Filed regression test, closing

@garrettmknight
Copy link
Contributor

$250 approved for @tienifr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
No open projects
Archived in project
Development

No branches or pull requests

9 participants