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

[$250] Search - Search tabs are blank instead of showing empty state in offline mode #47604

Closed
6 tasks done
IuliiaHerets opened this issue Aug 17, 2024 · 19 comments
Closed
6 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Monthly KSv2

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Aug 17, 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: v9.0.21-3
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Log in.
  3. Do not open Search page.
  4. Go offline.
  5. Go to Search.

Expected Result:

Search tabs will show empty state instead of blank in offline mode (previous behavior).

Actual Result:

Search tabs are blank in offline mode.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6574888_1723925312307.20240818_040635.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0105023dd56503c746
  • Upwork Job ID: 1825991013663261123
  • Last Price Increase: 2024-08-27
  • Automatic offers:
    • akinwale | Reviewer | 103709463
    • dominictb | Contributor | 103709465
Issue OwnerCurrent Issue Owner: @garrettmknight
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 17, 2024
@IuliiaHerets
Copy link
Author

We think that this bug might be related to #wave-collect - Release 1

Copy link

melvin-bot bot commented Aug 17, 2024

Triggered auto assignment to @garrettmknight (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.

@IuliiaHerets
Copy link
Author

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

@Krishna2323
Copy link
Contributor

Proposal

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

Search - Search tabs are blank instead of showing empty state in offline mode

What is the root cause of that problem?

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

We should remove !isOffline check.

What alternative solutions did you explore? (Optional)

  1. Instead of getting type from SearchUtils.getSearchType(searchResults?.search);, we should get the type from queryJSON.
    const type = SearchUtils.getSearchType(searchResults?.search);
    if (searchResults === undefined || type === undefined) {
    Log.alert('[Search] Undefined search type');
    return null;
    }
    const ListItem = SearchUtils.getListItem(type, status);
    const data = SearchUtils.getSections(type, status, searchResults.data, searchResults.search);
    const sortedData = SearchUtils.getSortedSections(type, status, data, sortBy, sortOrder);
    const sortedSelectedData = sortedData.map((item) => mapToItemWithSelectionInfo(item, selectedTransactions, canSelectMultiple));
    const shouldShowEmptyState = !isDataLoaded || data.length === 0;
    if (shouldShowEmptyState) {
    return (
    <>
    <SearchPageHeader
    isCustomQuery={isCustomQuery}
    queryJSON={queryJSON}
    hash={hash}
    />
    <EmptySearchView type={type} />
    </>
    );
    }

    const {status, sortBy, sortOrder, hash} = queryJSON;
  • Or we can modify the type constant to const type = SearchUtils.isSearchDataType(searchResults?.search?.type ?? queryType);
  1. We also need to update the searchResults === undefined || type === undefined condition to searchResults === undefined && type === undefined
    3.Additionally we also need to modify the constants below to ensure we don't get any error when searchResults is undefined:
    const ListItem = SearchUtils.getListItem(type, status);
    const data = SearchUtils.getSections(type, status, searchResults.data, searchResults.search);
    const sortedData = SearchUtils.getSortedSections(type, status, data, sortBy, sortOrder);
    const sortedSelectedData = sortedData.map((item) => mapToItemWithSelectionInfo(item, selectedTransactions, canSelectMultiple));

TO:

    const ListItem = SearchUtils.getListItem(type, status);
    const data = SearchUtils.getSections(type, status, searchResults?.data ?? [], searchResults?.search ?? []);
    const sortedData = SearchUtils.getSortedSections(type, status, data, sortBy, sortOrder);
    const sortedSelectedData = sortedData.map((item) => mapToItemWithSelectionInfo(item, selectedTransactions, canSelectMultiple));
Updated Code
    const type = (searchResults?.search?.type ?? queryType) as SearchDataTypes;
    const isValidType = SearchUtils.isSearchDataType(type);

    if (searchResults === undefined && !isValidType) {
        Log.alert('[Search] Undefined search type');
        return null;
    }

    const ListItem = SearchUtils.getListItem(type, status);
    const data = SearchUtils.getSections(type, status, searchResults?.data ?? {}, searchResults?.search ?? []);
    const sortedData = SearchUtils.getSortedSections(type, status, data, sortBy, sortOrder);
    const sortedSelectedData = sortedData.map((item) => mapToItemWithSelectionInfo(item, selectedTransactions, canSelectMultiple));

    const shouldShowEmptyState = !isDataLoaded || data.length === 0;

    if (shouldShowEmptyState) {
        return (
            <>
                <SearchPageHeader
                    isCustomQuery={isCustomQuery}
                    queryJSON={queryJSON}
                    hash={hash}
                />
                <EmptySearchView type={type} />
            </>
        );
    }

OPTIONAL: We can also use const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP); to show loading state when shouldShowLoadingState || isLoadingApp is true.

@wildan-m
Copy link
Contributor

Proposal

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

Search tabs display blank instead of showing an empty state in offline mode.

What is the root cause of that problem?

We return empty component when the searchResults and type undefined

if (searchResults === undefined || type === undefined) {
Log.alert('[Search] Undefined search type');
return null;
}

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

If searchResults and type are undefined, it means the loading process hasn't started. In this case, it's better to display a loading skeleton instead of an empty state. However, if loading has started once and we reload it offline, then we can show an empty state.

Instead of returning empty component, I think this logic searchResults === undefined || type === undefined should be present at shouldShowLoadingState

Move up the logic and show loading state instead of empty component.
src/components/Search/index.tsx

    const type = SearchUtils.getSearchType(searchResults?.search);
    const isDataLoaded = searchResults?.data !== undefined;
    const shouldShowLoadingState = (!isOffline && !isDataLoaded) || (searchResults === undefined || type === undefined);

Branch for this solution.

What alternative solutions did you explore? (Optional)

N/A

@dominictb
Copy link
Contributor

Proposal

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

Search tabs are blank in offline mode.

What is the root cause of that problem?

When we didn't call Search API yet, and go offline, then open Search page, function SearchActions.search is not called:

useEffect(() => {
if (isOffline) {
return;
}
SearchActions.search({queryJSON, offset, policyIDs});
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [isOffline, offset, queryJSON]);

In there, searchResults data is undefined:

const searchResults = currentSearchResults?.data ? currentSearchResults : lastSearchResultsRef.current;

so we display empty view:

if (searchResults === undefined || type === undefined) {
Log.alert('[Search] Undefined search type');
return null;
}

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

When we haven't called Search API yet, in other words, there is no snapshot_ data in onyx, we should not show the empty state because the empty state should be displayed when we already call Search API but the result is empty.

When we are in offline, we should not display the loading state because the loading state is used to indicates that we're trying to load something, but infact we're not actually loading anything as user is offline.

Based on the above, we should display the offline page, indicating that user is offline and we're unable to load. It is our pattern D in the Offline UX. So just need to update:

return null;

to:

        return <FullPageOfflineBlockingView>{null}</FullPageOfflineBlockingView>;

Demo

image

What alternative solutions did you explore? (Optional)

We can update:

if (searchResults === undefined || type === undefined) {
Log.alert('[Search] Undefined search type');
return null;
}

    if (searchResults === undefined) {
        return (
            <>
                <SearchPageHeader
                    isCustomQuery={isCustomQuery}
                    queryJSON={queryJSON}
                    hash={hash}
                />
                <EmptySearchView />
            </>
        );
    }

    if (type === undefined) {
        Log.alert('[Search] Undefined search type');
        return null;
    }

@melvin-bot melvin-bot bot added the Overdue label Aug 20, 2024
@garrettmknight garrettmknight added the External Added to denote the issue can be worked on by a contributor label Aug 20, 2024
@melvin-bot melvin-bot bot changed the title Search - Search tabs are blank instead of showing empty state in offline mode [$250] Search - Search tabs are blank instead of showing empty state in offline mode Aug 20, 2024
Copy link

melvin-bot bot commented Aug 20, 2024

Job added to Upwork: https://www.upwork.com/jobs/~0105023dd56503c746

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 20, 2024
Copy link

melvin-bot bot commented Aug 20, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label Aug 20, 2024
@garrettmknight garrettmknight moved this to Release 2: Summer 2024 (Aug) in [#whatsnext] #expense Aug 20, 2024
Copy link

melvin-bot bot commented Aug 26, 2024

@garrettmknight, @akinwale Huh... This is 4 days overdue. Who can take care of this?

@melvin-bot melvin-bot bot added the Overdue label Aug 26, 2024
@garrettmknight
Copy link
Contributor

@akinwale can you take a look at these proposals?

Copy link

melvin-bot bot commented Aug 27, 2024

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

@akinwale
Copy link
Contributor

@dominictb's proposal is the best approach here.

🎀👀🎀 C+ reviewed.

Copy link

melvin-bot bot commented Aug 27, 2024

Triggered auto assignment to @puneetlath, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

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

melvin-bot bot commented Aug 27, 2024

📣 @akinwale 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Aug 27, 2024

📣 @dominictb 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@Krishna2323
Copy link
Contributor

Krishna2323 commented Aug 27, 2024

@akinwale, I believe it will cause inconsistency because pages like categories, tags show empty state instead of offline state.

Sorry, I see that in those pages we have option to add the tags.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Aug 28, 2024
@dominictb
Copy link
Contributor

dominictb commented Sep 18, 2024

@garrettmknight This hit production on Sep 11 on should be ready for payment today. #48791 (comment)

@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels Sep 20, 2024
Copy link

melvin-bot bot commented Sep 20, 2024

This issue has not been updated in over 15 days. @puneetlath, @garrettmknight, @akinwale, @dominictb eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@garrettmknight garrettmknight removed the Reviewing Has a PR in review label Sep 23, 2024
@garrettmknight
Copy link
Contributor

Payment Summary:

@github-project-automation github-project-automation bot moved this from Release 2: Summer 2024 (Aug) to Done in [#whatsnext] #expense Sep 23, 2024
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. External Added to denote the issue can be worked on by a contributor Monthly KSv2
Projects
Archived in project
Development

No branches or pull requests

7 participants