Skip to content

[N6] Wrong value in AddressSearch after refresh #5840

Closed

Description

@aldo-expensify

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. Create NewDot account, verify it, log in
  2. Create Workspace
  3. Do the add Bank account step (first step) of VBA flow (use this SO)
  4. You should be in Company Step
  5. Type something in the Company Address field, choose an address result
  6. Type something in another field
  7. Refresh the page

Expected Result:

The Company Address field should have the value we input before refresh

Actual Result:

The Company Address doesn't have the right value:

Screen.Recording.2021-10-13.at.5.21.35.PM.mov

Workaround:

The user can input the address again

Platform:

Where is this issue occurring?

  • Web
  • iOS
  • Android
  • Desktop App
  • Mobile Web

Version Number:
Reproducible in staging?:
Reproducible in production?:
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Expensify/Expensify Issue URL:
Issue reported by:
Slack conversation:

View all open jobs on GitHub

Activity

  1. added
    AutoAssignerTriage
    Daily
    on Oct 14, 2021
  2. MelvinBot commented on Oct 14, 2021

    @MelvinBot
    Contributor

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

  3. removed
    AutoAssignerTriage
    on Oct 14, 2021
  4. trjExpensify commented on Oct 14, 2021

    @trjExpensify
    Contributor

    Ah yeah, I hit the undefined, undefined bit too. Noted that here: https://expensify.slack.com/archives/C020EPP9B9A/p1634207884072800?thread_ts=1634147967.452400&cid=C020EPP9B9A

    Are you taking this one on, @aldo-expensify?

  5. added
    Improvement
    on Oct 14, 2021
  6. roryabraham commented on Oct 14, 2021

    @roryabraham
    Contributor

    I'm investigating this now.

  7. self-assigned this
    on Oct 14, 2021
  8. roryabraham commented on Oct 14, 2021

    @roryabraham
    Contributor

    I'm not able to reproduce this.

  9. aldo-expensify commented on Oct 14, 2021

    @aldo-expensify
    ContributorAuthor

    I'm not able to reproduce this.

    I'll try too, maybe it has been solved 🤷

  10. roryabraham commented on Oct 14, 2021

    @roryabraham
    Contributor

    jk it happens with 88 Kearney Street

  11. MitchExpensify commented on Oct 14, 2021

    @MitchExpensify
    Contributor

    Feel free to bring this to a thread in the Slack room if you need people to help out reproducing / to talk the investigation through there - Usually gets more eyes than GH if needed, up to you!

  12. roryabraham commented on Oct 14, 2021

    @roryabraham
    Contributor

    I've got a potential fix I want to try

  13. aldo-expensify commented on Oct 14, 2021

    @aldo-expensify
    ContributorAuthor

    One thing I noticed is that when we pass from the "Add Bank account" step to the "Company information" step, the url changes to /bank-account/company for a brief moment and then it goes back to /bank-account/

    Screen Shot 2021-10-14 at 9 26 01 AM

    I would have expected it to be /bank-account/company during the 'Company information' step

    So.. this makes it take you back to the first step when you reload, but the bug still happens once you add the bank account again

  14. 14 remaining items

  15. aldo-expensify commented on Oct 14, 2021

    @aldo-expensify
    ContributorAuthor

    Yeah, so it looks like the type: address doesn't cover that case alone. Is it safe to assume that any valid address street must start with a number?

    you are right, it is missing the number :(

    If so, we should throw an error when the end result does not begin with a number?

    I guess that is an option, I'll have a look again to see if there is a way we could filter incomplete results

  16. aldo-expensify commented on Oct 14, 2021

    @aldo-expensify
    ContributorAuthor

    Is it safe to assume that any valid address street must start with a number?

    I think this is probably a safe assumption 99.99% of the time, so if we find counter-examples then we can handle them when they pop up?

    I think you are probably right there

  17. aldo-expensify commented on Oct 14, 2021

    @aldo-expensify
    ContributorAuthor

    Since we are doing a proxy in Web-Expensify, we could filter the results there if they are incomplete (if we are not able to filter them in the front end).

  18. roryabraham commented on Oct 14, 2021

    @roryabraham
    Contributor

    Okay, I just found this SO which appears relevant. Basically in the case of 25220 Quail Ridge Road, Escondido, CA, 97027, Google Places is returning a best-guess partial match, and the response should include a partial_match field that we should validate is false (exact matches only).

  19. aldo-expensify commented on Oct 14, 2021

    @aldo-expensify
    ContributorAuthor

    It seems to be missing the partial_match stuff in this case.

    The response when we search for 25220 Quail Ridge Road, Escondido, CA, 97027:

    {
       "predictions" : [
          {
             "description" : "Quail Ridge Road, Escondido, CA, USA",
             "matched_substrings" : [
                {
                   "length" : 16,
                   "offset" : 0
                }
             ],
             "place_id" : "EiRRdWFpbCBSaWRnZSBSb2FkLCBFc2NvbmRpZG8sIENBLCBVU0EiLiosChQKEgkhAGJPs_PbgBGZpcyAIyGoBRIUChIJe0PCgV7z24AR38WWdw_I0QE",
             "reference" : "EiRRdWFpbCBSaWRnZSBSb2FkLCBFc2NvbmRpZG8sIENBLCBVU0EiLiosChQKEgkhAGJPs_PbgBGZpcyAIyGoBRIUChIJe0PCgV7z24AR38WWdw_I0QE",
             "structured_formatting" : {
                "main_text" : "Quail Ridge Road",
                "main_text_matched_substrings" : [
                   {
                      "length" : 16,
                      "offset" : 0
                   }
                ],
                "secondary_text" : "Escondido, CA, USA"
             },
             "terms" : [
                {
                   "offset" : 0,
                   "value" : "Quail Ridge Road"
                },
                {
                   "offset" : 18,
                   "value" : "Escondido"
                },
                {
                   "offset" : 29,
                   "value" : "CA"
                },
                {
                   "offset" : 33,
                   "value" : "USA"
                }
             ],
             "types" : [ "route", "geocode" ]
          },
          {
             "description" : "25220 Quail Ridge Road, Escondido, CA, USA",
             "matched_substrings" : [
                {
                   "length" : 16,
                   "offset" : 6
                },
                {
                   "length" : 9,
                   "offset" : 24
                },
                {
                   "length" : 2,
                   "offset" : 35
                }
             ],
             "place_id" : "EioyNTIyMCBRdWFpbCBSaWRnZSBSb2FkLCBFc2NvbmRpZG8sIENBLCBVU0EiLiosChQKEgkhAGJPs_PbgBGZpcyAIyGoBRIUChIJe0PCgV7z24AR38WWdw_I0QE",
             "reference" : "EioyNTIyMCBRdWFpbCBSaWRnZSBSb2FkLCBFc2NvbmRpZG8sIENBLCBVU0EiLiosChQKEgkhAGJPs_PbgBGZpcyAIyGoBRIUChIJe0PCgV7z24AR38WWdw_I0QE",
             "structured_formatting" : {
                "main_text" : "25220 Quail Ridge Road",
                "main_text_matched_substrings" : [
                   {
                      "length" : 16,
                      "offset" : 6
                   }
                ],
                "secondary_text" : "Escondido, CA, USA",
                "secondary_text_matched_substrings" : [
                   {
                      "length" : 9,
                      "offset" : 0
                   },
                   {
                      "length" : 2,
                      "offset" : 11
                   }
                ]
             },
             "terms" : [
                {
                   "offset" : 0,
                   "value" : "25220"
                },
                {
                   "offset" : 6,
                   "value" : "Quail Ridge Road"
                },
                {
                   "offset" : 24,
                   "value" : "Escondido"
                },
                {
                   "offset" : 35,
                   "value" : "CA"
                },
                {
                   "offset" : 39,
                   "value" : "USA"
                }
             ],
             "types" : [ "route", "geocode" ]
          },
          {
             "description" : "25220 Quail Ridge Road, Los Gatos, CA, USA",
             "matched_substrings" : [
                {
                   "length" : 5,
                   "offset" : 0
                },
                {
                   "length" : 16,
                   "offset" : 6
                },
                {
                   "length" : 2,
                   "offset" : 35
                }
             ],
             "place_id" : "ChIJleyzZm05joARLy5PZi-_lQc",
             "reference" : "ChIJleyzZm05joARLy5PZi-_lQc",
             "structured_formatting" : {
                "main_text" : "25220 Quail Ridge Road",
                "main_text_matched_substrings" : [
                   {
                      "length" : 5,
                      "offset" : 0
                   },
                   {
                      "length" : 16,
                      "offset" : 6
                   }
                ],
                "secondary_text" : "Los Gatos, CA, USA",
                "secondary_text_matched_substrings" : [
                   {
                      "length" : 2,
                      "offset" : 11
                   }
                ]
             },
             "terms" : [
                {
                   "offset" : 0,
                   "value" : "25220"
                },
                {
                   "offset" : 6,
                   "value" : "Quail Ridge Road"
                },
                {
                   "offset" : 24,
                   "value" : "Los Gatos"
                },
                {
                   "offset" : 35,
                   "value" : "CA"
                },
                {
                   "offset" : 39,
                   "value" : "USA"
                }
             ],
             "types" : [ "premise", "geocode" ]
          },
          {
             "description" : "25220 Quail Ridge Road, Lafayette, CA, USA",
             "matched_substrings" : [
                {
                   "length" : 16,
                   "offset" : 6
                },
                {
                   "length" : 2,
                   "offset" : 35
                }
             ],
             "place_id" : "EioyNTIyMCBRdWFpbCBSaWRnZSBSb2FkLCBMYWZheWV0dGUsIENBLCBVU0EiLiosChQKEglFkwEeA2OFgBHA9dOymuW4uhIUChIJhY_6o3xghYARJ2nkA11YKPk",
             "reference" : "EioyNTIyMCBRdWFpbCBSaWRnZSBSb2FkLCBMYWZheWV0dGUsIENBLCBVU0EiLiosChQKEglFkwEeA2OFgBHA9dOymuW4uhIUChIJhY_6o3xghYARJ2nkA11YKPk",
             "structured_formatting" : {
                "main_text" : "25220 Quail Ridge Road",
                "main_text_matched_substrings" : [
                   {
                      "length" : 16,
                      "offset" : 6
                   }
                ],
                "secondary_text" : "Lafayette, CA, USA",
                "secondary_text_matched_substrings" : [
                   {
                      "length" : 2,
                      "offset" : 11
                   }
                ]
             },
             "terms" : [
                {
                   "offset" : 0,
                   "value" : "25220"
                },
                {
                   "offset" : 6,
                   "value" : "Quail Ridge Road"
                },
                {
                   "offset" : 24,
                   "value" : "Lafayette"
                },
                {
                   "offset" : 35,
                   "value" : "CA"
                },
                {
                   "offset" : 39,
                   "value" : "USA"
                }
             ],
             "types" : [ "route", "geocode" ]
          },
          {
             "description" : "25220 Quail Ridge Road, Cottonwood, CA, USA",
             "matched_substrings" : [
                {
                   "length" : 22,
                   "offset" : 0
                },
                {
                   "length" : 2,
                   "offset" : 36
                }
             ],
             "place_id" : "EisyNTIyMCBRdWFpbCBSaWRnZSBSb2FkLCBDb3R0b253b29kLCBDQSwgVVNBIlISUAo0CjIJYag1F-PQ0lQRWUdj8RBzGoEaHgsQ7sHuoQEaFAoSCXsZGyUR2dJUEUcXZjSo6-y6DBCExQEqFAoSCXFam0jR1tJUEWT9gTuLBLHV",
             "reference" : "EisyNTIyMCBRdWFpbCBSaWRnZSBSb2FkLCBDb3R0b253b29kLCBDQSwgVVNBIlISUAo0CjIJYag1F-PQ0lQRWUdj8RBzGoEaHgsQ7sHuoQEaFAoSCXsZGyUR2dJUEUcXZjSo6-y6DBCExQEqFAoSCXFam0jR1tJUEWT9gTuLBLHV",
             "structured_formatting" : {
                "main_text" : "25220 Quail Ridge Road",
                "main_text_matched_substrings" : [
                   {
                      "length" : 22,
                      "offset" : 0
                   }
                ],
                "secondary_text" : "Cottonwood, CA, USA",
                "secondary_text_matched_substrings" : [
                   {
                      "length" : 2,
                      "offset" : 12
                   }
                ]
             },
             "terms" : [
                {
                   "offset" : 0,
                   "value" : "25220 Quail Ridge Road"
                },
                {
                   "offset" : 24,
                   "value" : "Cottonwood"
                },
                {
                   "offset" : 36,
                   "value" : "CA"
                },
                {
                   "offset" : 40,
                   "value" : "USA"
                }
             ],
             "types" : [ "street_address", "geocode" ]
          }
       ],
       "status" : "OK"
    }

    The when we click it and it looks for details:

    {
       "html_attributions" : [],
       "result" : {
          "address_components" : [
             {
                "long_name" : "Quail Ridge Road",
                "short_name" : "Quail Ridge Rd",
                "types" : [ "route" ]
             },
             {
                "long_name" : "Escondido",
                "short_name" : "Escondido",
                "types" : [ "locality", "political" ]
             },
             {
                "long_name" : "San Diego County",
                "short_name" : "San Diego County",
                "types" : [ "administrative_area_level_2", "political" ]
             },
             {
                "long_name" : "California",
                "short_name" : "CA",
                "types" : [ "administrative_area_level_1", "political" ]
             },
             {
                "long_name" : "United States",
                "short_name" : "US",
                "types" : [ "country", "political" ]
             },
             {
                "long_name" : "92027",
                "short_name" : "92027",
                "types" : [ "postal_code" ]
             }
          ],
          "adr_address" : "\u003cspan class=\"street-address\"\u003eQuail Ridge Rd\u003c/span\u003e, \u003cspan class=\"locality\"\u003eEscondido\u003c/span\u003e, \u003cspan class=\"region\"\u003eCA\u003c/span\u003e \u003cspan class=\"postal-code\"\u003e92027\u003c/span\u003e, \u003cspan class=\"country-name\"\u003eUSA\u003c/span\u003e",
          "formatted_address" : "Quail Ridge Rd, Escondido, CA 92027, USA",
          "geometry" : {
             "location" : {
                "lat" : 33.1037195,
                "lng" : -117.0338186
             },
             "viewport" : {
                "northeast" : {
                   "lat" : 33.10506848029149,
                   "lng" : -117.0324696197085
                },
                "southwest" : {
                   "lat" : 33.10237051970849,
                   "lng" : -117.0351675802915
                }
             }
          },
          "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/geocode-71.png",
          "icon_background_color" : "#7B9EB0",
          "icon_mask_base_uri" : "https://maps.gstatic.com/mapfiles/place_api/icons/v2/generic_pinlet",
          "name" : "Quail Ridge Road",
          "place_id" : "EihRdWFpbCBSaWRnZSBSZCwgRXNjb25kaWRvLCBDQSA5MjAyNywgVVNBIi4qLAoUChIJIQBiT7Pz24ARmaXMgCMhqAUSFAoSCXtDwoFe89uAEd_FlncPyNEB",
          "reference" : "EihRdWFpbCBSaWRnZSBSZCwgRXNjb25kaWRvLCBDQSA5MjAyNywgVVNBIi4qLAoUChIJIQBiT7Pz24ARmaXMgCMhqAUSFAoSCXtDwoFe89uAEd_FlncPyNEB",
          "types" : [ "route" ],
          "url" : "https://maps.google.com/?q=Quail+Ridge+Rd,+Escondido,+CA+92027,+USA&ftid=0x80dbf3b34f620021:0x5a8212380cca599",
          "utc_offset" : -420,
          "vicinity" : "Escondido"
       },
       "status" : "OK"
    }
  20. aldo-expensify commented on Oct 14, 2021

    @aldo-expensify
    ContributorAuthor

    It looks like we complete the data with a second request. The first request pulling the results list include less information in the response, which would make it a bit harder to know that some results are a problem. I guess we could still do the check if there is a number at the start to confirm that the address is complete.

  21. roryabraham commented on Oct 14, 2021

    @roryabraham
    Contributor

    Okay, here's what I suggest we do:

    1. Include type: address in the query.
    2. Validate that one of the address_components has a types array that contains street_number
    3. Validate that none of the address_components has a types array that contains post_box
  22. aldo-expensify commented on Oct 14, 2021

    @aldo-expensify
    ContributorAuthor

    Okay, here's what I suggest we do:

    1. Include type: address in the query.
    2. Validate that one of the address_components has a types array that contains street_number
    3. Validate that none of the address_components has a types array that contains post_box

    That sounds good to me, but I would suggest doing (2) and (3) as filters in our backend so we don't show those results to the user. I think it is better experience than showing results that eventually will lead to validation errors. What do you think about that? scratch that, we can't do that there because we don't have that information at that time (autocomplete query)

  23. roryabraham commented on Oct 14, 2021

    @roryabraham
    Contributor

    That sounds good to me, but I would suggest doing (2) and (3) as filters in our backend so we don't show those results to the user. I think it is better experience than showing results that eventually will lead to validation errors. What do you think about that?

    I'm not sure I understand this suggestion. I'm suggesting that if a user attempts to select an address from the GooglePlacesAutocomplete component with this properties, then we know that it's an invalid address for our purposes, and we'll display an error in the form.

  24. aldo-expensify commented on Oct 14, 2021

    @aldo-expensify
    ContributorAuthor

    I'm not sure I understand this suggestion. I'm suggesting that if a user attempts to select an address from the GooglePlacesAutocomplete component with this properties, then we know that it's an invalid address for our purposes, and we'll display an error in the form.

    My suggestion was toward filtering out bad results in our backend so the user never see them, but it is not so easy as I thought.

    I'll implement the validations you suggested in the front, or if you want, you can implement them, what do you prefer?

  25. roryabraham commented on Oct 14, 2021

    @roryabraham
    Contributor

    It might not be a perfect solution, but it will be an improvement from what we have currently. We can address issues with other addresses as they come up. I think we should maybe also add some unit test coverage of the saveLocationDetails function to help maintain it in the future.

  26. aldo-expensify commented on Oct 14, 2021

    @aldo-expensify
    ContributorAuthor

    Updated the PR, it is still in WIP since it is missing the suggested tests, but let me know if that implementation makes sense for you @roryabraham . Thank you!

  27. MitchExpensify commented on Oct 14, 2021

    @MitchExpensify
    Contributor

    What is the estimate on the PR being ready for review? Anything I can do to help?

  28. aldo-expensify commented on Oct 14, 2021

    @aldo-expensify
    ContributorAuthor

    What is the estimate on the PR being ready for review? Anything I can do to help?

    Hmm, I have to update the "Steps / QA" section. I can do that now. About the tests that @roryabraham suggested, I'm having some doubts about it.

    To make it easier to test, I would remove the function saveLocationDetails from AddressSearch and make it receive a callback onChangeText as a parameter. This function is very related to the AddressSearch component and probably won't be used anywhere else, so I'm a bit hesitant about moving it to a separate file just for testing purposes. Another option is to define it in the AddressSearch component file and export it from there, but I haven't seen another case where we export something else besides the component.

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

Metadata

Metadata

Labels

DailyEngineeringImprovement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions