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

Invoice - Send invoice button appears in Reports empty state when invited member is not an admin #54562

Open
8 tasks done
IuliiaHerets opened this issue Dec 25, 2024 · 4 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2

Comments

@IuliiaHerets
Copy link

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: 9.0.78-2
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team
Device used: Mac 15.0 / Chrome
App Component: Search

Action Performed:

Precondition:

  • User B does not have invoice feature enabled in any workspace, or use a new account.
  1. Go to staging.new.expensify.com
  2. Create a workspace.
  3. Go to workspace settings > More features.
  4. Enable Invoices.
  5. Invite User B to the workspace.
  6. Log in as User B.
  7. Go to Search > Invoices.
  8. Click Send invoice.

Expected Result:

Send invoice button should not appear for User B since User B is not an admin of the invited workspace.

Actual Result:

Send invoice button appears for User B when User B is not an admin of the invited workspace. It opens not here page.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6702000_1735113983672.20241225_160207.mp4

View all open jobs on GitHub

@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Dec 25, 2024
Copy link

melvin-bot bot commented Dec 25, 2024

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

@FitseTLT
Copy link
Contributor

FitseTLT commented Dec 25, 2024

Edited by proposal-police: This proposal was edited at 2024-12-25 14:58:57 UTC.

Proposal

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

Invoice - Send invoice button appears in Reports empty state when invited member is not an admin

What is the root cause of that problem?

We are not check if a user can send invoice before displaying the button here

{
buttonText: translate('workspace.invoices.sendInvoice'),
buttonAction: () =>
interceptAnonymousUser(() => {
if (shouldRedirectToExpensifyClassic) {
setModalVisible(true);
return;
}
IOU.startMoneyRequest(CONST.IOU.TYPE.INVOICE, ReportUtils.generateReportID());
}),
success: true,

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

We should check if user can send invoice check we use here

const canSendInvoice = useMemo(() => PolicyUtils.canSendInvoice(allPolicies as OnyxCollection<OnyxTypes.Policy>, session?.email), [allPolicies, session?.email]);

and only display the button if the can send invoice

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

What alternative solutions did you explore? (Optional)

@etCoderDysto
Copy link
Contributor

etCoderDysto commented Dec 25, 2024

Edited by proposal-police: This proposal was edited at 2024-12-25 15:08:51 UTC.

Proposal

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

Send invoice button appears in Reports empty state when invited member is not an admin

What is the root cause of that problem?

EmptySearchView returns the copy below when type is invoice without considering if the user is an admin

case CONST.SEARCH.DATA_TYPES.INVOICE:
if (!hasResults) {
return {
headerMedia: LottieAnimations.GenericEmptyState,
title: translate('search.searchResults.emptyInvoiceResults.title'),
subtitle: translate('search.searchResults.emptyInvoiceResults.subtitle'),
buttons: [
...(!hasSeenTour
? [
{
buttonText: translate('emptySearchView.takeATour'),
buttonAction: () => {

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

  1. We should check if the user can send invoice using PolicyUtils.canSendInvoice
  2. Then we should return a new custom copy and button here if the user can't send an invoice, and has no results. If they can, we can display the current copy.

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

What alternative solutions did you explore? (Optional)

We can use canSendInvoice instead of hasWorkspaceWithInvoices to hide the invoice option from left hand navigation if the user is not admin and didn't have invoice reports

if (hasWorkspaceWithInvoices(session?.email) || hasInvoiceReports()) {

const canSendInvoice = PolicyUtils.canSendInvoice(allPolicies, currentUserLogin);

Invoice option will be displayed only when there are invoices for a non-admin user

POC

Screenshot 2024-12-25 at 6 33 21 in the evening

@etCoderDysto
Copy link
Contributor

Added an alternative solution

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. Daily KSv2
Projects
None yet
Development

No branches or pull requests

4 participants