Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.17k stars 2.66k forks source link

Distance - Map centers on users location after permission to access location is denied #45090

Closed lanitochka17 closed 1 week ago

lanitochka17 commented 2 weeks ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.0.5-2 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/4700585 Issue reported by: Applause - Internal Team

Action Performed:

  1. Navigate to staging.new.expensify.com
  2. Disallow expensify to access user's location and go to troubleshoot and clear cache and restart
  3. Go to workspace chat and start a distance expense flow
  4. Observe the prompt to allow access to user's location and observe the map being centered on San Francisco
  5. Allow expensify to access user's location
  6. Start a distance expense flow and observe the map now centers on user's location
  7. Disallow expensify to access user's location again
  8. Start a distance expense flow and observe the map

Expected Result:

Map should center on San Francisco

Actual Result:

Map centers on user's current location based on the saved cache but if user clears cache and restarts then map centers on San Francisco

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/Expensify/App/assets/78819774/87a55c1f-1fb6-4e55-8206-88f212f16e76

View all open jobs on GitHub

melvin-bot[bot] commented 2 weeks ago

Triggered auto assignment to @anmurali (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 commented 2 weeks ago

@anmurali 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

jacobkim9881 commented 2 weeks ago

Clearing cache doesn't seem to reset the users location. Users location is saved in Onyx(local database) I think. Let me know the answer.

dominictb commented 2 weeks ago

Proposal

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

What is the root cause of that problem?

const checkPermission = async () => {
    try {
        let permissionStatus;

        if (Platform.OS === 'ios') {
            permissionStatus = await check(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE);
        } else if (Platform.OS === 'android') {
            permissionStatus = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);
        }

        if (permissionStatus !== RESULTS.GRANTED) {
            UserLocation.clearUserLocation();
        }
    } catch (err) {
        console.warn(err);
    }
};

useEffect(() => {
        checkPermission();
    }, []);

What alternative solutions did you explore? (Optional)

melvin-bot[bot] commented 2 weeks ago

@anmurali Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

melvin-bot[bot] commented 1 week ago

@anmurali Still overdue 6 days?! Let's take care of this!

anmurali commented 1 week ago

Hmm I cannot reproduce. Map does go back to centering in SF. I am also not sure why this is an issue? It doesn't seem like a problem if it doesn't actually behave this way.

dominictb commented 1 week ago

@anmurali

https://github.com/user-attachments/assets/bd881af2-f60a-48fe-9a25-d86c10a4a086