Open lanitochka17 opened 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.
Edited by proposal-police: This proposal was edited at 2024-11-15 06:30:48 UTC.
Search - Search view does not reset to Expenses after disabling Invoices feature
PolicyUtils.hasWorkspaceWithInvoices(session?.email) || hasInvoiceReports()
is false.
https://github.com/Expensify/App/blob/11a8f6746bbfbea67c5087776ee438ec9672b847/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx#L45-L62
queryJSON.type === 'invoice'
is true and PolicyUtils.hasWorkspaceWithInvoices(session?.email) || hasInvoiceReports()
is false, in that case we will update the type to expense
.session
from const [session] = useOnyx(ONYXKEYS.SESSION);
and pass it to handleQueryWithPolicyID
.Same should be done in both BottomTabBar
files. We can also create a util function for refactoring the code.
function handleQueryWithPolicyID(query: SearchQueryString, activePolicyID?: string, session?: Session): SearchQueryString {
const queryJSON = SearchQueryUtils.buildSearchQueryJSON(query);
...code
if (queryJSON.type === 'invoice' && !(PolicyUtils.hasWorkspaceWithInvoices(session?.email) || hasInvoiceReports())) {
queryJSON.type = 'expense';
}
return SearchQueryUtils.buildSearchQueryString(queryJSON);
}
queryJSON
when the invoices type is disabled and queryJSON.type === 'invoice'
is true.buildCannedSearchQuery
when resetting the type.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);
}
type === 'invoice'
is true and if it is then navigate with the default query.
https://github.com/Expensify/App/blob/a6f1348d08a441f4f9b48a8ef05e5e95c96b53d7/src/pages/Search/SearchTypeMenu.tsx#L96-L106
if (hasWorkspaceWithInvoices(session?.email) || hasInvoiceReports()) {
typeMenuItems.push({
title: translate('workspace.common.invoices'),
type: CONST.SEARCH.DATA_TYPES.INVOICE,
icon: Expensicons.InvoiceGeneric,
getRoute: (policyID?: string) => {
const query = SearchQueryUtils.buildCannedSearchQuery({type: CONST.SEARCH.DATA_TYPES.INVOICE, status: CONST.SEARCH.STATUS.INVOICE.ALL, policyID});
return ROUTES.SEARCH_CENTRAL_PANE.getRoute({query});
},
});
} else if (type === 'invoice') {
Navigation.navigate(
ROUTES.SEARCH_CENTRAL_PANE.getRoute({
query: SearchQueryUtils.buildCannedSearchQuery(),
}),
);
}
Search view does not reset to Expenses after disabling Invoices feature
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.
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]);
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.
@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.
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
Not overdue - I think this isn't a priority - but will get some more eyes to gut check
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