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.56k stars 2.9k forks source link

Search - Search view does not reset to Expenses after disabling Invoices feature #52590

Open lanitochka17 opened 4 days ago

lanitochka17 commented 4 days 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.62-3 Reproducible in staging?: Y Reproducible in production?: Y If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A If this was caught during regression testing, add the test name, ID and link from TestRail: N/A Email or phone of affected tester (no customers): applausetester+w8@applause.expensifail.com Issue reported by: Applause - Internal Team

Action Performed:

Precondition:

Expected Result:

The entire Search page should reset to Expenses since Invoices are disabled

Actual Result:

Search page still remains on Invoices view, while Search LHN has nothing highlighted

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/user-attachments/assets/76e70156-f1c5-4c08-81a9-1b683393187a

View all open jobs on GitHub

melvin-bot[bot] commented 4 days ago

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

Krishna2323 commented 4 days ago

Edited by proposal-police: This proposal was edited at 2024-11-15 06:30:48 UTC.

Proposal


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

Search - Search view does not reset to Expenses after disabling Invoices feature

What is the root cause of that problem?

What alternative solutions did you explore? (Optional)

function handleQueryWithPolicyID(query: SearchQueryString, activePolicyID?: string, session?: Session): SearchQueryString {
    let queryJSON = SearchQueryUtils.buildSearchQueryJSON(query);
    ...code
    if (queryJSON.type === 'invoice' && !(PolicyUtils.hasWorkspaceWithInvoices(session?.email) || hasInvoiceReports())) {
        queryJSON = SearchQueryUtils.buildSearchQueryJSON(SearchQueryUtils.buildCannedSearchQuery({policyID: queryJSON.policyID}));
    }

    return SearchQueryUtils.buildSearchQueryString(queryJSON);
}

What alternative solutions did you explore? (Optional 2)

Result

huult commented 4 days ago

Proposal

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

Search view does not reset to Expenses after disabling Invoices feature

What is the root cause of that problem?

The params still exist with type = invoices after returning to the SearchPageBottomTab because we didn't clear the type type = invoices after disabling the invoices feature.

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

To resolve this issue, we need to navigate to SEARCH_CENTRAL_PANE with the scanned search query if the invoice is disabled. We will add this logic in SearchType, ensuring it matches the logic for hiding/showing the invoice. If the invoice is hidden in the search type, the invoices page will still not be displayed.

// src/pages/Search/SearchTypeMenu.tsx#197
    useLayoutEffect(() => {
        if (type !== CONST.SEARCH.DATA_TYPES.INVOICE) {
            return;
        }
        if (hasWorkspaceWithInvoices(session?.email) || hasInvoiceReports()) {
            return;
        }

        Navigation.navigate(
            ROUTES.SEARCH_CENTRAL_PANE.getRoute({
                query: SearchQueryUtils.buildCannedSearchQuery(),
            }),
        );
    }, [session?.email, type]);
POC https://github.com/user-attachments/assets/12dcc32f-c509-4c84-a0cf-616cb58d5751
Krishna2323 commented 4 days ago

PROPOSAL UPDATE

OfstadC commented 3 days ago

Hmmm... The Search page is sticky by design, yeah? If I click "Chat" and navigate elsewhere, come back - i'm still on the Chat page.

I don't think we need to do anything here. If they had past invoices, they'd still need to be accessible, even if the feature was disabled.

Krishna2323 commented 3 days ago

@OfstadC, if invoices option is not shown in the LHP then it means that the user doesn't have any invoices or any workspace with invoices enabled. In that case we shouldn't stick to "invoices" page. In the original post you can verify that the invoices option in LHP isn't shown when coming back to search page after disabling the invoices feature.

OfstadC commented 3 days ago

I'm just not sure this is worth fixing. In the case they have Invoices, the stickiness is helpful. In the case where they don't, it doesn't really harm any workflow. They can navigate away from Invoices. This seems like it's not worth prioritizing

OfstadC commented 15 hours ago

Not overdue - I think this isn't a priority - but will get some more eyes to gut check