-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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-11-20] [$125] [Search v2.2] Remove Invoice type from LHN if workspaces don't have it enabled #51620
Comments
Triggered auto assignment to @alexpensify ( |
Job added to Upwork: https://www.upwork.com/jobs/~021851031006738225317 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @eVoloshchak ( |
Upwork job price has been updated to $125 |
Edited by proposal-police: This proposal was edited at 2024-10-28 22:58:42 UTC. ProposalPlease re-state the problem that we are trying to solve in this issue.[Search v2.2] Remove Invoice type from LHN if workspaces don't have it enabled What is the root cause of that problem?Improvement What changes do you think we should make in order to solve the problem?
function hasPolicyWithEnabledInvoice() {
return Object.values(allPolicies ?? {}).some((policy) => {
return policy && policy.areInvoicesEnabled && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
});
}
const isInvoiceEnabled = useMemo(() => PolicyUtils.hasPolicyWithEnabledInvoice(), [allPolicies]); App/src/pages/Search/SearchTypeMenu.tsx Lines 90 to 98 in 8ef040a
if (PolicyUtils.hasPolicyWithEnabledInvoice()) {
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});
},
});
}
What alternative solutions did you explore? (Optional)
const typeMenuItems: SearchTypeMenuItem[] = [
{
title: translate('common.expenses'),
type: CONST.SEARCH.DATA_TYPES.EXPENSE,
icon: Expensicons.Receipt,
getRoute: (policyID?: string) => {
const query = SearchQueryUtils.buildCannedSearchQuery({policyID});
return ROUTES.SEARCH_CENTRAL_PANE.getRoute({query});
},
},
{
title: translate('common.chats'),
type: CONST.SEARCH.DATA_TYPES.CHAT,
icon: Expensicons.ChatBubbles,
getRoute: (policyID?: string) => {
const query = SearchQueryUtils.buildCannedSearchQuery({type: CONST.SEARCH.DATA_TYPES.CHAT, status: CONST.SEARCH.STATUS.CHAT.ALL, policyID});
return ROUTES.SEARCH_CENTRAL_PANE.getRoute({query});
},
},
...((PolicyUtils.hasPolicyWithEnabledInvoice()
? [
{
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});
},
},
]
: []),
{
title: translate('travel.trips'),
type: CONST.SEARCH.DATA_TYPES.TRIP,
icon: Expensicons.Suitcase,
getRoute: (policyID?: string) => {
const query = SearchQueryUtils.buildCannedSearchQuery({type: CONST.SEARCH.DATA_TYPES.TRIP, status: CONST.SEARCH.STATUS.TRIP.ALL, policyID});
return ROUTES.SEARCH_CENTRAL_PANE.getRoute({query});
},
},
]; Result |
I think this part is incorrect. We want to push it to the array if you have any policies with invoices enabled in Onyx. |
@luacmartins, I have updated my proposal . |
ProposalPlease re-state the problem that we are trying to solve in this issue.Remove Invoice type from LHN in Search if it is not enabled What is the root cause of that problem?Invoice type is added to search LHN from here and it is always added to the LHN Menu even if user does not use invoices. What changes do you think we should make in order to solve the problem?A user will only use invoices if it is enabled in one of their workspaces or they have received an invoice from somebody else as admins can send Invoice to users outside their workspace and the user will not be added to workspace. So, we need to update here to only add Invoices to menu items if they have a workspace with invoices or an invoice has been sent to them. The updated logic would look like this. The Implementation can be done like below: Current: App/src/pages/Search/SearchTypeMenu.tsx Lines 71 to 108 in b2d14a1
New: const session = useOnyx(ONYXKEYS.SESSION)
const typeMenuItems = [
...
]
if (PolicyUtils.hasWorkspaceWithInvoices(session?.email) || ReportUtils.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});
},
})
typeMenuItems.push({
title: translate('travel.trips'),
type: CONST.SEARCH.DATA_TYPES.TRIP,
...
}) Policies with InvoiceWe can reuse some of the logic from the Send Invoice button for FAB, which currently looks like this: Lines 597 to 612 in ce01614
so, hasWorkspaceWithInvoices will look like: function hasWorkspaceWithInvoices(currentUserLogin) {
const activePolicies = getActivePolicies(allPolicies);
return activePolicies.some((policy) => shouldShowPolicy(policy, NetworkStore.isOffline(), currentUserLogin) && policy.areInvoicesEnabled);
} Invoice Report to external membersfunction hasInvoiceReports() {
const allReports = ReportConnection.getAllReports();
return allReports.some(report => isInvoiceReport(report))
} Note: all the code samples are for explaination only and can be improved during PR What alternative solutions did you explore? (Optional)Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job. |
@eVoloshchak - when you get a chance, can you please review if one of these proposals will fix the issue? Thanks! |
@alexpensify, @eVoloshchak, @luacmartins Uh oh! This issue is overdue by 2 days. Don't forget to update your issues! |
@eVoloshchak any update here? Thanks! |
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸 |
@eVoloshchak please keep me posted if you are unable to review. I will need to reassign by Wednesday if no answer. |
@alexpensify, @eVoloshchak, @luacmartins Still overdue 6 days?! Let's take care of this! |
@eVoloshchak any updates here? |
I am not available right now but I can work on it tomorrow so if it's urgent please assign it to @Krishna2323 Also, I think whoever implements it should be compensated so, if it's assigned to @Krishna2323 then they should be compensated. |
Sure, I'll reassign to you @jaydamani since you're proposal was more complete as @Krishna2323 pointed out above. |
📣 @jaydamani 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
Starting work on this |
Created PR |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.60-3 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-11-20. 🎊 For reference, here are some details about the assignees on this issue:
|
BugZero Checklist: The PR adding this new feature has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
|
Payouts due: 2024-11-20
Upwork job is here. |
Closing |
$125 approved for @rushatgabhane |
Problem
We currently show
Invoice
as a Search type in the LHN for users, but that's confusing if they never enabled that featureSolution
Avoid confusion and remove the
Invoice
type if users don't have this option enabled in any of their policiesUpwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @alexpensifyThe text was updated successfully, but these errors were encountered: