Skip to content

[Due for payment 2026-05-20] [$250] Reports - type:expense-report query not applied when from:me #86603

Closed

Description

@jponikarchuk

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: v9.3.50-2
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/folder/13176922/test-cases/41237519
Email or phone of affected tester (no customers): applausetester+la4jjj@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Windows 11, Chrome | iPhone SE 3rd generation, iOS 26.4
App Component: Search

Action Performed:

Preconditions:

  • The user is signed in with an Expensifail account.
  • The user has a unsubmitted expense in the workspace.
  1. Go to https://staging.new.expensify.com/
  2. Navigate to Reports > Expenses
  3. Copy this: type:expense-report action:submit from:me (note: any query using from:me does not work)
  4. Paste it on the search field 'Search for something' and press Enter, or select the first highlighted option.

Expected Result:

After pasting type:expense-report action:submit from:me and selecting the first highlighted option or pressing Enter, me should turn green, and the system should correctly apply the filter, returning only the expense reports submitted by the current user.

Actual Result:

When the query type:expense-report action:submit from:me is used, me does not turn green, meaning it is not detected. The system redirects to the expected page but fails to filter by me, showing unfiltered results instead

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Video.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022037804379216972874
  • Upwork Job ID: 2037804379216972874
  • Last Price Increase: 2026-05-02
  • Automatic offers:
    • wildan-m | Contributor | 111364060

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Mar 28, 2026
  2. MelvinBot commented on Mar 28, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The me keyword in search queries (e.g., from:me) is not a grammar-level construct — it's purely a display-layer convention. The entire me workflow depends on the substitution map being populated when the user selects themselves from the autocomplete dropdown.

    When using autocomplete (works): Selecting "me" from the dropdown triggers SearchRouter.tsx:283-285 to add {"from:me": "<accountID>"} to the substitution map. The validation function filterOutRangesWithCorrectValue at SearchAutocompleteUtils.ts:190 then finds the substitution entry, turns "me" green, and on submit getQueryWithSubstitutions replaces "me" with the actual accountID.

    When pasting/typing directly (broken): No autocomplete interaction occurs, so the substitution map is never populated. Two things fail:

    1. Highlighting fails — filterOutRangesWithCorrectValue (SearchAutocompleteUtils.ts:190) checks substitutionMap["from:me"] (undefined) and userLogins.includes("me") (false, since userLogins contains emails). So "me" never turns green. Notably, parseForLiveMarkdown at line 280 does check for CONST.SEARCH.ME, but it runs in .map() after the .filter() that already rejected the range.

    2. Query substitution fails — getQueryWithSubstitutions finds no substitution entry, so "me" passes through literally. Then getUpdatedFilterValue (SearchQueryUtils.ts:309-310) calls getPersonalDetailByEmail("me") which returns undefined because "me" is not a real email. The literal string "me" gets sent to the backend instead of the user's accountID.

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

    Two changes are needed:

    1. Fix highlighting — In filterOutRangesWithCorrectValue (src/libs/SearchAutocompleteUtils.ts:190), add || range.value === CONST.SEARCH.ME to the return condition for the personal filter keys (FROM, TO, ASSIGNEE, PAYER, EXPORTER, ATTENDEE). This ensures "me" turns green even when typed/pasted without autocomplete.

    2. Fix query substitution — In getUpdatedFilterValue (src/libs/SearchQueryUtils.ts:309-310), add a check: if filterValue === CONST.SEARCH.ME, resolve it to the current user's accountID (available via currentUserAccountID$ Onyx value or getCurrentUserAccountID()) before falling through to the email lookup. This ensures the query sends the numeric accountID to the backend instead of the literal string "me".

    What alternative solutions did you explore? (Optional)

    An alternative would be to handle this in buildSubstitutionsMap by detecting when a raw query contains from:me and auto-populating the substitution map entry. However, this would be more complex and fragile since buildSubstitutionsMap is designed for the reverse direction (accountID → display value). The proposed fix addresses the problem at the two exact points of failure with minimal changes.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Mar 28, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Mar 28, 2026
  5. melvin-bot commented on Mar 28, 2026

    @melvin-bot

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

  6. melvin-bot commented on Mar 28, 2026

    @melvin-bot
  7. changed the title [-]Reports - type:expense-report query not applied when from:me[/-] [+][$250] Reports - type:expense-report query not applied when from:me[/+] on Mar 28, 2026
  8. wildan-m commented on Mar 28, 2026

    @wildan-m
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-04-22 01:56:33 UTC.

    Proposal

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

    When pasting or typing from:me (or any user filter with me) in the search input, me does not turn green and the filter is not applied. The search results are unfiltered because the backend receives the literal string me instead of the current user's account ID.

    What is the root cause of that problem?

    There are two failure points when me is typed/pasted directly (without autocomplete selection):

    1. Highlighting validation rejects me

    filterOutRangesWithCorrectValue validates whether a filter value should be highlighted (turn green). For user-based filters, it only checks the substitution map and the userLogins list — neither contains me when typed/pasted without autocomplete:

    case CONST.SEARCH.SYNTAX_FILTER_KEYS.TO:
    case CONST.SEARCH.SYNTAX_FILTER_KEYS.FROM:
    case CONST.SEARCH.SYNTAX_FILTER_KEYS.ASSIGNEE:
    case CONST.SEARCH.SYNTAX_FILTER_KEYS.PAYER:
    case CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTER:
    case CONST.SEARCH.SYNTAX_FILTER_KEYS.ATTENDEE:
    return substitutionMap[`${range.key}:${range.value}`] !== undefined || userLogins.get().includes(range.value);

    The substitution map is empty because no autocomplete selection populated it. And userLogins contains real email addresses, not the special me keyword. So the range is filtered out before it even reaches parseForLiveMarkdown line 280 which does check for CONST.SEARCH.ME — but only in .map() after .filter() already rejected it.

    2. Query substitution cannot resolve me to an account ID

    getQueryWithSubstitutions replaces display values with internal IDs (e.g., from:@johndoe → from:9876) using the substitution map. When me is pasted directly, the substitution map has no entry for it, so me passes through literally to getUpdatedFilterValue, which then calls getPersonalDetailByEmail("me") — returns undefined because me is not an email — and the literal string me is sent to the backend:

    https://github.com/Expensify/App/blob/e42712830efb4e3bae9e9569769c4ee508dc71c2/src/components/Search/SearchRouter/getQueryWithSubstitutions.ts#L30-L78

    The autocomplete flow avoids this because selecting me from the dropdown populates the substitution map with from:me → <accountID> before submit. But when pasting, the substitution map is empty, so me passes through unresolved.

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

    1. Fix highlighting — In filterOutRangesWithCorrectValue (src/libs/SearchAutocompleteUtils.ts line 190), add || range.value === CONST.SEARCH.ME to the return condition for user-based filter keys (FROM, TO, ASSIGNEE, PAYER, EXPORTER, ATTENDEE). This ensures me turns green immediately when typed/pasted, consistent with how parseForLiveMarkdown at line 280 already treats it as a valid current-user mention.

    2. Fix query substitution — Add an optional currentUserAccountID parameter to getQueryWithSubstitutions. When a parsed range has value === CONST.SEARCH.ME on a user-based filter key and has no existing substitution entry, fall back to the account ID. Update the two existing call sites (useSearchPageInput.tsx line 121 and SearchRouter.tsx line 242) to pass currentUserAccountID — both components already read it via useOnyx(ONYXKEYS.SESSION, {selector: accountIDSelector}). This threads the session context through without violating the rulesdir/no-onyx-connect lint rule that bans new module-level Onyx subscriptions.

    Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/86603-from-me-search-filter?expand=1

    Per @luacmartins's clarification, from:me filters on report.accountID regardless of state/action — resolving me to the session account ID for ALL user-based filters (rather than gating by action like submit/approve/pay/export) matches the intended semantics. The backend handles the per-filter interpretation (from = report accountID; payer/exporter/approver = their respective fields).

    What alternative solutions did you explore? (Optional)

    1. Fix in buildSubstitutionsMap by auto-populating from:me → accountID when parsing a query. This would fix the page-reload case (URL containing from:me), but not the initial paste-and-submit case — buildSubstitutionsMap runs in a useEffect tied to the URL query, so it has not run for the pasted text by the time the user presses Enter. A centralized fix in getQueryWithSubstitutions covers both paths.

    2. Fix in getUpdatedFilterValue (in SearchQueryUtils.ts) by resolving me to the account ID there. This would also work, but getUpdatedFilterValue is a pure utility with no hook or parameter access to currentUserAccountID, so it would require either adding a parameter through multiple call chains or adding an Onyx.connect subscription. The new rulesdir/no-onyx-connect rule discourages the latter. Fixing at the substitution layer stays within the component code path that already has the session account ID.

  9. added a commit that references this issue on Mar 28, 2026
    6b1a2e4
  10. wildan-m commented on Mar 28, 2026

    @wildan-m
    Contributor

    Proposal

    Updated

    Added compare branch with implementation.

  11. anobie commented on Mar 28, 2026

    @anobie

    🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

  12. github-actions commented on Mar 28, 2026

    @github-actions
    Contributor

    ⚠️ @anobie Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  13. 87 remaining items

  14. huult commented on May 18, 2026

    @huult
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      It seems this is a new feature.

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: N/A

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue: https://github.com/Expensify/Expensify/issues/639578

    Regression Test Proposal

    Precondition:

    • Signed in with an account that has at least one unsubmitted expense in the workspace.

    Test:

    1. Go to Expensify.
    2. Navigate to Reports > Expenses.
    3. Copy this: type:expense-report action:submit from:me
    4. Paste it on the search field "Search for something" and press Enter, or select the first highlighted option.
    5. Verify me turns green and the system correctly applies the filter, returning only the expense reports submitted by the current user.

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-dd42-a7ff-7068-5c80419eb834
  15. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on May 18, 2026
  16. melvin-bot commented on May 19, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  17. mallenexpensify commented on May 21, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @wildan-m paid $250 via Upwork
    Contributor+: @huult due $250 via NewDot

    ^ Test case created. Thx

    Thx

  18. JmillsExpensify commented on Jun 2, 2026

    @JmillsExpensify
    Contributor

    $250 approved for @huult

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions