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 2024-07-22] [$500] Distance - Search list displays old searched results in offline mode #30123

Closed
6 tasks done
lanitochka17 opened this issue Oct 21, 2023 · 89 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 Design Engineering External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item.

Comments

@lanitochka17
Copy link

lanitochka17 commented Oct 21, 2023

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: 1.3.88-3
Reproducible in staging?: Yes
Reproducible in production?: Yes
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
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go offline
  3. Click on FAB> Request money> Distance tab
  4. Select Start point
  5. Enter any letter into search field

Expected Result:

Search result should update according to entered letter

Actual Result:

Search list displays old searched results in offline mode

Workaround:

Unknown

Platforms:

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

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

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
Windows: Chrome
Bug6245602_1697901225387.Recording__1286.mp4
MacOS: Desktop

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01a86156cf627cbc84
  • Upwork Job ID: 1715774289180717056
  • Last Price Increase: 2024-06-28
  • Automatic offers:
    • cooldev900 | Contributor | 27794398
Issue OwnerCurrent Issue Owner: @eVoloshchak
@lanitochka17 lanitochka17 added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 21, 2023
@melvin-bot melvin-bot bot changed the title Distance - Search list displays old searched results in offline mode [$500] Distance - Search list displays old searched results in offline mode Oct 21, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 21, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 21, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01a86156cf627cbc84

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

melvin-bot bot commented Oct 21, 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
Copy link

melvin-bot bot commented Oct 21, 2023

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

@cooldev900
Copy link
Contributor

cooldev900 commented Oct 21, 2023

Proposal

from: @cooldev900

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

GooglePlacesAutocomplete shows old selected results in offline mode.

What is the root cause of that problem?

The route cause is that if the app turns to offline state, requestUrl.url becomes null and it couldn't send location filter request to google API.

url: props.network.isOffline ? null : ApiUtils.getCommandURL({command: 'Proxy_GooglePlaces&proxyUrl='}),

https://github.com/FaridSafi/react-native-google-places-autocomplete/blob/ef107387c6846924423b832a242eee83cb07eed4/GooglePlacesAutocomplete.js#L158

const [url, setUrl] = useState(getRequestUrl(props.requestUrl));

https://github.com/FaridSafi/react-native-google-places-autocomplete/blob/ef107387c6846924423b832a242eee83cb07eed4/GooglePlacesAutocomplete.js#L508-L511

 const _request = (text) => {
    _abortRequests();
    if (!url) {
      return;

https://github.com/FaridSafi/react-native-google-places-autocomplete/blob/ef107387c6846924423b832a242eee83cb07eed4/GooglePlacesAutocomplete.js#L88-L125

const [tempSearchedValue, setTempsearchedValue] = useState([])

  const buildRowsFromResults = useCallback(
    (results, text) => {
      let res = [];
      const shouldDisplayPredefinedPlaces = text
        ? results.length === 0 && text.length === 0
        : results.length === 0;
      if (
        shouldDisplayPredefinedPlaces ||
        props.predefinedPlacesAlwaysVisible === true
      ) {
        res = [
          ...props.predefinedPlaces.filter(
            (place) => place?.description.length,
          ),
        ];

        if (props.currentLocation === true && hasNavigator()) {
          res.unshift({
            description: props.currentLocationLabel,
            isCurrentLocation: true,
          });
        }
      }

      res = res.map((place) => ({
        ...place,
        isPredefinedPlace: true,
      }));

      return [...res, ...results];
    },
    [
      props.currentLocation,
      props.currentLocationLabel,
      props.predefinedPlaces,
      props.predefinedPlacesAlwaysVisible,
    ],
  );

And then even if we change the input value, the request won't will be run in request function so dataSource state value doesn't change.
As a result, GooglePlaceAutocomplete compoment shows old search result.

And if we don't search anything and it turns to offline, the predefined places shows in GooglePlaceAutocomplete.

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

Regarding discussion, we can filter recent destination by user's input in offline and send it as a props to GooglePlacesAutocomplete.

const filteredPredefinedPlaces = useMemo(() => {
        console.log({predefinedPlaces: props.predefinedPlaces})
        if (!props.network.isOffline || !searchValue) return props.predefinedPlaces.length < 5 ? props.predefinedPlaces : props.predefinedPlaces.slice(0, 5);
        const filterRecentPlaces = props.predefinedPlaces.filter(value => !value?.description ? false :searchValue.split(" ").some((searchTerm) => value?.description.toLocaleLowerCase.includes(searchTerm.toLocaleLowerCase())))
        return filterRecentPlaces.length < 5 ? filterRecentPlaces : filterRecentPlaces.slice(0, 5);
    }, [
        props.network.isOffline, props.predefinedPlaces, searchValue
    ])

    return (
        /*
         * The GooglePlacesAutocomplete component uses a VirtualizedList internally,
         * and VirtualizedLists cannot be directly nested within other VirtualizedLists of the same orientation.
         * To work around this, we wrap the GooglePlacesAutocomplete component with a horizontal ScrollView
         * that has scrolling disabled and would otherwise not be needed
         */
        <>
            <ScrollView
                horizontal
                contentContainerStyle={styles.flex1}
                scrollEnabled={false}
                // keyboardShouldPersistTaps="always" is required for Android native,
                // otherwise tapping on a result doesn't do anything. More information
                // here: https://github.com/FaridSafi/react-native-google-places-autocomplete#use-inside-a-scrollview-or-flatlist
                keyboardShouldPersistTaps="always"
            >
                <View
                    style={styles.w100}
                    ref={containerRef}
                >
                    <GooglePlacesAutocomplete
                        disableScroll
                        fetchDetails
                        suppressDefaultStyles
                        enablePoweredByContainer={false}
                        predefinedPlaces={filteredPredefinedPlaces}      

_.map(waypoints ? waypoints.slice(0, 5) : [], (waypoint) => ({

_.map(waypoints ? waypoints.slice(0, 20) : [], (waypoint) => ({

Onyx.merge(ONYXKEYS.NVP_RECENT_WAYPOINTS, clonedWaypoints.slice(0, 5));

Onyx.merge(ONYXKEYS.NVP_RECENT_WAYPOINTS, clonedWaypoints.slice(0, 20));

What alternative solutions did you explore? (Optional)

N/A

Result

screen-capture.2.webm

@shubham1206agra
Copy link
Contributor

@cooldev900 This has not been merged yet
#29045

Can you send the video with your solution?

@shubham1206agra
Copy link
Contributor

If this is an upstream bug, @FaridSafi might help you with this

@cooldev900
Copy link
Contributor

I will upload the video.

@cooldev900
Copy link
Contributor

cooldev900 commented Oct 22, 2023

ice_video_20231022-084232.webm
const filteredPredefinedPlaces = useMemo(() => {
        if (!props.network.isOffline || !searchValue) return props.predefinedPlaces
        return props.predefinedPlaces.filter(value => value?.description.toLocaleLowerCase().includes(searchValue.toLocaleLowerCase()))
    }, [
        props.network.isOffline, props.predefinedPlaces, searchValue
    ])

    return (
        /*
         * The GooglePlacesAutocomplete component uses a VirtualizedList internally,
         * and VirtualizedLists cannot be directly nested within other VirtualizedLists of the same orientation.
         * To work around this, we wrap the GooglePlacesAutocomplete component with a horizontal ScrollView
         * that has scrolling disabled and would otherwise not be needed
         */
        <>
            <ScrollView
                horizontal
                contentContainerStyle={styles.flex1}
                scrollEnabled={false}
                // keyboardShouldPersistTaps="always" is required for Android native,
                // otherwise tapping on a result doesn't do anything. More information
                // here: https://github.com/FaridSafi/react-native-google-places-autocomplete#use-inside-a-scrollview-or-flatlist
                keyboardShouldPersistTaps="always"
            >
                <View
                    style={styles.w100}
                    ref={containerRef}
                >
                    <GooglePlacesAutocomplete
                        disableScroll
                        fetchDetails
                        suppressDefaultStyles
                        enablePoweredByContainer={false}
                        predefinedPlaces={filteredPredefinedPlaces}

@shubham1206agra @FaridSafi
As a alternative, I showed only how to search predefined places in SearchAddress.js component in offline mode.
We can fix it successfully with @FaridSafi by modifying react-native-google-places-autocomplete.

@melvin-bot melvin-bot bot added the Overdue label Oct 24, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 25, 2023

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

@mallenexpensify
Copy link
Contributor

@eVoloshchak , can you please review the above proposal?

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

melvin-bot bot commented Oct 28, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@eVoloshchak
Copy link
Contributor

@cooldev900, thank you for the proposal!

There are two ways we could go with this:

  1. Implement the approach @cooldev900 is proposing, which is to save the search results we got when online and use them while offline
  2. Disable the ability to create a Distance money request while offline

The problem with the first approach is that we'll be saving only a fraction of places (only those that the user has searched for earlier), so while offline this won't be very useful. Additionally, there will be no clear indication that the search is "restricted" while offline, it will essentially half-work, which is worse than not working at all imo

@mallenexpensify, what do you think?

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

I'm unsure, can you create a post in #expensify-open-source (since #expensify-bugs is being deprecated for External) and tag me in it? I'll cross-post in the internal distance room. Thx

@melvin-bot melvin-bot bot added the Overdue label Nov 2, 2023
Copy link

melvin-bot bot commented Nov 3, 2023

@eVoloshchak, @mallenexpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

@mallenexpensify
Copy link
Contributor

@eVoloshchak can you create the #expensify-open-source post then drop the link in here? Thx

@melvin-bot melvin-bot bot removed the Overdue label Nov 3, 2023
Copy link

melvin-bot bot commented Nov 4, 2023

@eVoloshchak @mallenexpensify 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!

Copy link

melvin-bot bot commented Jun 28, 2024

Upwork job price has been updated to $500

@mallenexpensify mallenexpensify added Reviewing Has a PR in review and removed Overdue labels Jun 28, 2024
Copy link

melvin-bot bot commented Jul 8, 2024

@eVoloshchak, @mallenexpensify, @neil-marcellini, @pac-guerreiro, @dubielzyk-expensify Huh... This is 4 days overdue. Who can take care of this?

@neil-marcellini neil-marcellini added Awaiting Payment Auto-added when associated PR is deployed to production and removed Reviewing Has a PR in review labels Jul 9, 2024
@neil-marcellini neil-marcellini added Weekly KSv2 and removed Daily KSv2 labels Jul 9, 2024
@melvin-bot melvin-bot bot removed the Overdue label Jul 9, 2024
@neil-marcellini
Copy link
Contributor

@mallenexpensify the PR was merged so this is awaiting payment now. Looks like the automation failed, would you please handle it manually?

@mallenexpensify
Copy link
Contributor

Contributor+: @eVoloshchak due $500 via NewDot

With many changes for offline distance bugs, do we want a new test case for this? I'm unsure

cc @paultsimura since it's an offline distance issue.

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Jul 15, 2024
@melvin-bot melvin-bot bot changed the title [$500] Distance - Search list displays old searched results in offline mode [HOLD for payment 2024-07-22] [$500] Distance - Search list displays old searched results in offline mode Jul 15, 2024
Copy link

melvin-bot bot commented Jul 15, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.6-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-07-22. 🎊

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

Copy link

melvin-bot bot commented Jul 15, 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:

  • [@eVoloshchak] The PR that introduced the bug has been identified. Link to the PR:
  • [@eVoloshchak] 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:
  • [@eVoloshchak] 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:
  • [@eVoloshchak] Determine if we should create a regression test for this bug.
  • [@eVoloshchak] 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.
  • [@mallenexpensify] 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 Overdue and removed Weekly KSv2 labels Jul 16, 2024
Copy link

melvin-bot bot commented Jul 22, 2024

Payment Summary

Upwork Job

BugZero Checklist (@mallenexpensify)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1715774289180717056/hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

Copy link

melvin-bot bot commented Jul 22, 2024

@eVoloshchak, @mallenexpensify, @neil-marcellini, @pac-guerreiro, @dubielzyk-expensify Eep! 4 days overdue now. Issues have feelings too...

@mallenexpensify
Copy link
Contributor

@eVoloshchak plz complete the BZ checklist above.

@melvin-bot melvin-bot bot removed the Overdue label Jul 22, 2024
@eVoloshchak
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: N/A, this functionality wasn't implemented initially
  • 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
  • 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: this was already discussed in https://expensify.slack.com/archives/C01GTK53T8Q/p1716990791744559

Regression Test Proposal

  1. Click on FAB> Submit Expense > Distance tab
  2. Select different locations several times to populate the predefined places list
  3. Turn off the internet connection
  4. Select Start point
  5. Start typing into the search field, verify the list is updated according to the search query

Do we agree 👍 or 👎

@mallenexpensify
Copy link
Contributor

mallenexpensify commented Jul 26, 2024

Contributor+: @eVoloshchak due $500 via NewDot

Test case

Thanks all!

@github-project-automation github-project-automation bot moved this from Release 1: Spring 2024 (May) to Done in [#whatsnext] #wave-collect Jul 26, 2024
@JmillsExpensify
Copy link

$500 approved for @eVoloshchak

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 Design Engineering External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item.
Projects
No open projects
Archived in project
Development

No branches or pull requests

10 participants