App icon indicating copy to clipboard operation
App copied to clipboard

[$175] [Exploratory] Invoice-Invoice received is not shown on searching type: invoice in spend section.

Open applause-bot[bot] opened this issue 1 month ago • 13 comments

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: V9.5.20-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/80268785/folder/13176671/130662267/1903875810?sort=%2Bname Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Redmi note 10s android 13 App Component: User Settings

Action Performed:

  1. Launch app
  2. Send invoice from user A to user B
  3. Open user B and search type: invoice
  4. Note invoice received is not shown
  5. Go to LHN and note invoice received is shown

Expected Result:

Invoice received must be shown on searching type: invoice in spend section.

Actual Result:

Invoice received is not shown on searching type: invoice in spend section.

Workaround:

Unknown

Platforms:

  • [x] Android: App
  • [ ] Android: mWeb Chrome
  • [ ] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [ ] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/66675614-cffe-42c1-8a56-06df9cbfbced

View all open jobs on GitHub

Applause Internal Information Exported by: Julia Ponikarchuk Bug ID: 7295064

Upwork Automation - Do Not Edit

applause-bot[bot] avatar Oct 26 '26 18:10 applause-bot[bot]

While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/b9bd555a460c868286579c58ae56beec1875b9830fa4774796f6d1de7f4773f9

applause-bot[bot] avatar Oct 26 '26 18:10 applause-bot[bot]

Issue Analysis

Root Cause: This appears to be a backend/internal issue. A separate internal investigation is needed.

The App sends type:invoice to the Search API with no extra filters, and it shows every invoice row the API returns. So when user B, the invoice receiver, gets no rows, the Search response most likely leaves out invoices they received. The LHN still shows the invoice because it reads the report from Onyx, not from Search.

Recommended Fix: You need to change the backend Search command, not the App. Escalate this to an internal engineer who can work on the backend.

Investigation details

No default invoice filter in the query

No client-side filter drops received invoices

Not verified

  • Production logs weren't available during this run. To confirm, check user B's Search request for type:invoice:
    • If the response has no invoice report or transaction, the backend is the cause.
    • If the response has them and they still don't show, check whether the transaction is missing a transactionID.

Alternative considered: a recent App regression. The client code above has no invoice- or receiver-specific filtering, so a client change is unlikely to cause this.


Next Steps: Reply with @MelvinBot <your feedback> to refine this analysis.


view run

MelvinBot avatar Nov 03 '26 00:11 MelvinBot

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

melvin-bot[bot] avatar Nov 03 '26 00:11 melvin-bot[bot]

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

melvin-bot[bot] avatar Nov 03 '26 00:11 melvin-bot[bot]

@aimane-chnaif Whoops! This issue is 2 days overdue. Let's get this updated quick!

melvin-bot[bot] avatar Nov 06 '26 21:11 melvin-bot[bot]

Proposal

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

When User A sends an invoice from a workspace to User B (an individual user who does not own an invoice-enabled workspace), User B receives the invoice in their LHN chat, but when User B navigates to Spend (Search) and searches type: invoice (or opens the Type filter dropdown), the received invoice is not shown and "Nothing to show" is displayed.

What is the root cause of that problem?

There are three layers to this issue across the search parser, the Type filter option guard, and the optimistic/local search state for an invoice receiver:

  1. searchParser.peggy does not allow whitespace after : in type: invoice, turning type: invoice into type:expense + keyword "invoice" (src/libs/SearchParser/searchParser.peggy, lines 65–115): Notice the exact query in the issue title and reproduction steps: searching type: invoice in spend section (with a space after the colon).

    • For User A (who has canSendInvoice(policies, currentUserLogin) === true), typing type: in the Search router shows Invoice in the autocomplete dropdown (useAutocompleteSuggestions.ts), which inserts type:invoice without a space.
    • For User B (an individual receiver with canSendInvoice === false), if Invoice is missing from the Type filter / autocomplete or the user types type: invoice with a space after the colon, searchParser.peggy fails to match filter because the grammar rule requires key ":" identifier with no horizontal whitespace after ":".
    • As a result, type: is parsed as a bare word and "invoice" is parsed as a free-text keyword against the default type: "expense", so the app sends type:expense with keyword "invoice" instead of type:invoice!
  2. hasInvoiceReports() in src/libs/ReportUtils.ts (lines 14852–14855) only checks isInvoiceReport(report) and misses isInvoiceRoom(report) and chatReport.iouReportID: In src/libs/SearchUIUtils.ts (line 5702):

    const shouldHideInvoiceOption = !canSendInvoice(policies, currentUserLogin) && !hasInvoiceReports();
    

    And in src/libs/ReportUtils.ts (lines 14852–14855):

    function hasInvoiceReports() {
        const reports = Object.values(deprecatedAllReports ?? {});
        return reports.some((report) => isInvoiceReport(report));
    }
    

    When User B receives an invoice notification via Pusher before opening the invoice room, Onyx has the invoice chat room (chatType: CONST.REPORT.CHAT_TYPE.INVOICE, i.e. isInvoiceRoom(report)) with iouReportID set, while the child type: CONST.REPORT.TYPE.INVOICE report object may not be loaded into ONYXKEYS.COLLECTION.REPORT yet. Consequently, hasInvoiceReports() returns false, hiding the Invoice option in TypeSelector (src/components/Search/FilterComponents/TypeSelector.tsx, line 56).

  3. TypeSelector.tsx does not subscribe to ONYXKEYS.COLLECTION.REPORT, so getTypeOptions uses a non-reactive call to hasInvoiceReports() (src/components/Search/FilterComponents/TypeSelector.tsx, lines 51–56): TypeSelector only subscribes to ONYXKEYS.COLLECTION.POLICY and ONYXKEYS.SESSION, so even when an invoice report arrives in ONYXKEYS.COLLECTION.REPORT, TypeSelector does not re-evaluate rigorously via useOnyx.

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

  1. In src/libs/ReportUtils.ts (hasInvoiceReports, lines 14852–14855): Check both isInvoiceReport(report) and isInvoiceRoom(report) so an individual user who has received an invoice in an invoice chat room is immediately recognized as having invoice reports:

    function hasInvoiceReports() {
        const reports = Object.values(deprecatedAllReports ?? {});
        return reports.some((report) => isInvoiceReport(report) || (isInvoiceRoom(report) && !!report?.iouReportID));
    }
    
  2. In src/libs/SearchParser/searchParser.peggy (and src/libs/SearchParser/autocompleteParser.peggy) followed by npm run build-parser: Allow optional horizontal whitespace ([ \t]*) immediately after the colon ":" in filter rules (e.g. type: invoice) so that typing type: invoice with a space after the colon parses as type: "invoice" instead of falling back to type: "expense" with keyword "invoice".

  3. In tests/unit/SearchParserTest.ts and tests/unit/SearchUIUtilsTest.ts: Add unit tests verifying that:

    • parseSearchQuery('type: invoice') parses type as CONST.SEARCH.DATA_TYPES.INVOICE with no leftover keyword filter.
    • getTypeOptions includes CONST.SEARCH.DATA_TYPES.INVOICE for a receiver who has an invoice room (chatType: CONST.REPORT.CHAT_TYPE.INVOICE with iouReportID) even when canSendInvoice is false.

What alternative solutions did you explore?

We also checked whether getTransactionsSections in src/libs/SearchUIUtils.ts filters out received invoices on the client when type === CONST.SEARCH.DATA_TYPES.INVOICE; it does not. Allowing optional space after : in searchParser.peggy and checking isInvoiceRoom(report) in hasInvoiceReports() ensures both manual type: invoice queries and the Type filter selector work for individual invoice receivers.

e5ash avatar Nov 07 '26 14:11 e5ash

📣 @pa-khan! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

melvin-bot[bot] avatar Nov 07 '26 14:11 melvin-bot[bot]

Proposal

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

When User A sends an invoice to User B ( receiver), User B sees the received invoice in the Left Hand Navigation (LHN), but when User B navigates to Spend and searches type:invoice, the received invoice does not appear in the search results.

What is the root cause of that problem?

This is caused by how the backend Search API scopes type:invoice queries, combined with no client-side optimistic search snapshot injection for the invoice receiver:

  1. In src/libs/SearchParser/searchParser.peggy (lines 65–70) and src/libs/actions/Search.ts (lines 1415–1427), searching type:invoice in the Spend section parses to {type: 'invoice', sortBy: 'date', sortOrder: 'desc', view: 'table'} and sends the Search command to the backend with jsonQuery.
  2. On the frontend, getTransactionsSections in src/libs/SearchUIUtils.ts renders every transaction returned in currentSearchResults?.data without filtering out received invoices.
  3. However, on the backend (Auth / Web-Expensify), type:invoice searches only return invoices belonging to workspace policies where the user is an admin/member (i.e., sent invoices managed under a workspace's Invoices feature). For an individual recipient (User B) who received the invoice in a personal invoice receiver room (chatType: 'invoice'), the backend Search query for type:invoice omits received invoices (returning data: {}), whereas the LHN displays the invoice chat because SidebarLinksData reads ONYXKEYS.COLLECTION.REPORT directly from Onyx.

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

This requires a backend change in the Search command handler (Web-Expensify / Auth):

  1. Update the backend Search query for type:invoice (CONST.SEARCH.DATA_Types.INVOICE) so that in addition to querying invoices on policies where the current user is an admin/member, it also includes invoice reports (type = 'invoice' / chatType = 'invoice') where the current user's accountID is the invoice receiver (managerID / participant on the invoice room).
  2. No frontend parser or table-rendering changes in Expensify/App are needed once the backend returns received invoice reports and transactions in the Search snapshot.

What alternative solutions did you explore? (Optional)

We checked whether Expensify/App could merge local ONYXKEYS.COLLECTION.REPORT invoice rooms into Search results on the client in src/libs/SearchUIUtils.ts, but Search snapshots are paginated and server-driven (currentSearchResults.data), so client-side injection would break pagination, sorting, and aggregations when the user has not opened every invoice report locally.

ghost avatar Nov 08 '26 15:11 ghost

📣 @jeff-graham-ai! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

melvin-bot[bot] avatar Nov 08 '26 15:11 melvin-bot[bot]

@aimane-chnaif this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

melvin-bot[bot] avatar Nov 09 '26 21:11 melvin-bot[bot]

@aimane-chnaif Still overdue 6 days?! Let's take care of this!

melvin-bot[bot] avatar Nov 10 '26 21:11 melvin-bot[bot]

@aimane-chnaif Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!

melvin-bot[bot] avatar Nov 12 '26 21:11 melvin-bot[bot]

This issue has not been updated in over 14 days. @aimane-chnaif eroding to Weekly issue.