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

Bank Account - Some addresses give error without red outline and no information on what's wrong #5867

Closed
isagoico opened this issue Oct 15, 2021 · 17 comments
Assignees

Comments

@isagoico
Copy link

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. Navigate to workspace
  2. Click on add bank account
  3. Connect with test credentials
  4. On the company address enter "64 Noll Street, Brooklyn, NY, USA" and select the option
  5. Enter the rest of the information in the fields
  6. Press continue.

Expected Result:

There's a error message mentioning the user what is wrong with the provided address.

Actual Result:

There's no information on why the address is not valid. Some addresses are valid and I have no idea why some are not.

Workaround:

Enter a valid address (?) I guess this is not valid if the user is entering a correct address here.

Platform:

Where is this issue occurring?

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

Version Number: 1.1.7-22

Reproducible in staging?: Yes
Reproducible in production?: No

Logs: https://stackoverflow.com/c/expensify/questions/4856

Notes/Photos/Videos: Any additional supporting documentation

Expensify/Expensify Issue URL:

Issue reported by: Applause
Slack conversation:

View all open jobs on GitHub

@isagoico isagoico added DeployBlockerCash This issue or pull request should block deployment Engineering Daily KSv2 labels Oct 15, 2021
@MelvinBot
Copy link

Triggered auto assignment to @tylerkaraszewski (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@isagoico
Copy link
Author

Oh I think this is related to this PR #5854 - @aldo-expensify

@aldo-expensify
Copy link
Contributor

The problem with that address and the result clicked is that the result is missing the locality that we use as the "city".

JSON obtained from the result:

[
    {
        "long_name": "64",
        "short_name": "64",
        "types": [
            "street_number"
        ]
    },
    {
        "long_name": "Noll Street",
        "short_name": "Noll St",
        "types": [
            "route"
        ]
    },
    {
        "long_name": "Bushwick",
        "short_name": "Bushwick",
        "types": [
            "neighborhood",
            "political"
        ]
    },
    {
        "long_name": "Brooklyn",
        "short_name": "Brooklyn",
        "types": [
            "sublocality_level_1",
            "sublocality",
            "political"
        ]
    },
    {
        "long_name": "Kings County",
        "short_name": "Kings County",
        "types": [
            "administrative_area_level_2",
            "political"
        ]
    },
    {
        "long_name": "New York",
        "short_name": "NY",
        "types": [
            "administrative_area_level_1",
            "political"
        ]
    },
    {
        "long_name": "United States",
        "short_name": "US",
        "types": [
            "country",
            "political"
        ]
    },
    {
        "long_name": "11206",
        "short_name": "11206",
        "types": [
            "postal_code"
        ]
    },
    {
        "long_name": "4604",
        "short_name": "4604",
        "types": [
            "postal_code_suffix"
        ]
    }
]

@aldo-expensify
Copy link
Contributor

Well, it seems like there will be cases where the "locality" (which is often a city) is missing:

https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform
Screen Shot 2021-10-14 at 8 06 04 PM

https://stackoverflow.com/questions/44774508/why-city-name-missing-for-some-locations-from-google-maps-api-result

Would be interesting to know which other cities in the US may have this problem.

What can we do about it? in this case we could use the administrative_area_level_1 if the locality is missing, but I'm not sure if that will work in all cases. I think the administrative_area_level_1 is the state, and in this case it matches the city name.

@kevinksullivan kevinksullivan removed the DeployBlockerCash This issue or pull request should block deployment label Oct 15, 2021
@kevinksullivan
Copy link
Contributor

Removing deploy blocker per https://expensify.slack.com/archives/C020EPP9B9A/p1634274922234500

@aldo-expensify aldo-expensify self-assigned this Oct 15, 2021
@aldo-expensify
Copy link
Contributor

aldo-expensify commented Oct 15, 2021

In the details of the selected result we have the location's coordinate. In the case of the address 64 Noll Street, Brooklyn, NY, USA , the latitude is 40.7007309 and longitude is -73.9332924.

I did a test to reverse geocode coordinates to see if that would find me the city. Api url request based on the coordinates:

https://maps.googleapis.com/maps/api/geocode/json?latlng=40.7007309,-73.9332924&key=XXX

(you can open this URL in the browser, if you have an api key - I found a key in slack)

This gives a bunch of results, but within the results, there was one that indeed had the city:

response.results.find(result => result.address_components.find(component => component.types.includes('locality')))

This yields

'{
    "address_components": [
        ...
        {
            "long_name": "New York",
            "short_name": "New York",
            "types": [
                "locality",
                "political"
            ]
        },
       ...
    ],
    ...
}'

I don't know yet how reliable is this. If it was reliable, would we consider following such approach? I did a few tests using addresses from Brooklyn, Bronx and Queens, which have the missing city problem, and I always found the city using the reverse geocoding.

The function I'm playing with looks like:

const reverseGeocode = (latitude, longitude) => {
        const apiKey = 'XXX';
        const proxiedUrl = `/geocode/json?latlng=${latitude},${longitude}&key=${apiKey}`;
        const url = `${CONFIG.EXPENSIFY.URL_EXPENSIFY_COM}api?command=Proxy_GooglePlaces&proxyUrl=${proxiedUrl}`;

        //`https://maps.googleapis.com/maps/api/geocode/json?latlng=${latitude},${longitude}&key=${apiKey}`
        fetch(url)
            .then(response => response.json())
            .then((response) => {
                console.log(response);
                const resultWithCity = response.results.find(result => result.address_components.find(component => component.types.includes('locality')));
                console.log(resultWithCity);
            });
    };

@aldo-expensify
Copy link
Contributor

@marcaaron @roryabraham what do you think about this? Would appreciate your opinion.

@MelvinBot MelvinBot removed the Overdue label Oct 19, 2021
@marcaaron
Copy link
Contributor

Can you summarize the problem? I'm not sure I understand what the issue is.

@aldo-expensify
Copy link
Contributor

aldo-expensify commented Oct 19, 2021

Can you summarize the problem? I'm not sure I understand what the issue is.

  1. Input an address in Brooklyn, i.e. "64 Noll Street, Brooklyn, NY, USA",
  2. Select the only result offered
  3. We get the different parts of the address (city, state, zipCode, streetName, streetNumber) from address_components in the result. In particular, we get the city from the "locality" address_components (see all address_components available here).
  4. There are some results that have the "locality" missing (some parts of NY, don't know if other places)
  5. This ends up blocking the user. The only result available is incomplete.

Currently this is affecting address in Brooklyn, Bronx and Queens, not sure if there are other neighbourhoods/cities with the problem.

One option I'm thinking about, is to complement the information using the the geocode API when there is something missing:

  • We get coordinates from the results from the places API
  • We can use those coordinates for the geocode API to get the missing city

Another option would be to just hardcode the problematic case of New York city, but we don't know if there could be other problematic cities.

@marcaaron
Copy link
Contributor

complement the information using the the geocode API when there is something missing

This sounds like something we may have to do anyway once we exhaust other alternatives. Tbh, I'm not sure what else could be done and the form is currently in a bad state. This is an edge case, but an important one (lots of people live in cities - if we can assume other cities like New York are affected). So, maybe we should be fixing this any way we possibly can and then discuss the good approach after 😄

Can we rule out that simply preferring to use the sublocality field if it's available and locality is unavailable? In this case, "Brooklyn" is the city we are looking for. It looks like the JSON you linked has that in it.

There are some results that have the "locality" missing (some parts of NY, don't know if other places)

I think we only need to worry about the US at the moment. Unsure if that helps narrow it down. I took a look at the docs you linked and I'm no less confused. I wish I could help more but don't have much experience with this API.

@roryabraham
Copy link
Contributor

I would be hesitant to start using the GPS coordinates to validate addresses – seems like that could lead to a near-infinite number of false positives if we're not careful, so if we can't find another solution I would prefer to hardcode the known exceptions of the boroughs of NYC.

But before going down that road, let's try what @marcaaron suggested and fall back on the sublocality if locality is missing? In any event, I really think the key to success on this component is unit tests. That way we can still manage to keep it working despite any hackiness or workarounds we have to implement.

@aldo-expensify
Copy link
Contributor

aldo-expensify commented Oct 19, 2021

I would be hesitant to start using the GPS coordinates to validate addresses – seems like that could lead to a near-infinite number of false positives if we're not careful

I was thinking that how prone to error it is depends on the type of information that we are trying to complete. A city probably would be correct by GPS coordinates, but a street could be more likely to be wrong.

In any case, since NY seems to be the only problematic case at the moment, I agree with you both of using sublocality if locality is missing for now and see if later other cases arise. Using this simpler solution may be enough.

What do we use the address information for? there won't be any problem in using Brooklyn as the city?

@marcaaron
Copy link
Contributor

there won't be any problem in using Brooklyn as the city?

Nope, Brooklyn is the city.

@aldo-expensify
Copy link
Contributor

aldo-expensify commented Oct 19, 2021

Nope, Brooklyn is the city.

😮 🤯

@tylerkaraszewski
Copy link
Contributor

I was assigned for triage but it looks like @aldo-expensify has this so I'm unassigning myself.

@tylerkaraszewski tylerkaraszewski removed their assignment Oct 20, 2021
@ogumen
Copy link

ogumen commented Oct 22, 2021

From the accessibility prospective, it fails WCAG success criteria 3.3.1 and 3.3.3 since it is not clear what the error is and how to fix it.

@aldo-expensify
Copy link
Contributor

Not overdue, PR waiting for review.

From the accessibility prospective, it fails WCAG success criteria 3.3.1 and 3.3.3 since it is not clear what the error is and how to fix it.

We will continue having poor error feedback for this field once the PR is merge, we should address this later. Two cases that will cause an error with poor feedback:

  • User types an address without selecting a result from the autocomplete
  • User selects a result from the autocomplete, but that result is not valid for us (route).

@MelvinBot MelvinBot removed the Overdue label Oct 22, 2021
@botify botify closed this as completed Oct 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants