Skip to content

[Due for payment 2026-05-15] [$250] Extra two significant figures are added to amount when searched from Recent searches #87285

Closed

Description

@nlemma

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.3.53-7
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://github.com/Expensify/Expensify/issues/567981
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Windows 10 - Chrome
App Component: Other

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to Reports > Expenses.
  3. Search with amount:123.
  4. Clear the search field.
  5. Click on the search field.
  6. Click type:expense amount:123 under Recent searches.

Expected Result:

The amount in "type:expense amount:123" will remain unchanged.

Actual Result:

The amount in "type:expense amount:123" changes to 12300.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7119335_1775075524945.bandicam_2026-04-01_23-25-00-358.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/~022041622122830675700
  • Upwork Job ID: 2041622122830675700
  • Last Price Increase: 2026-04-28

Activity

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

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    When a recent search is clicked from the search page header, submitSearch in useSearchPageInput.tsx:116-129 correctly skips amount conversion for the query param (via shouldSkipAmountConversion = true), but unconditionally passes queryWithSubstitutions as rawQuery — which already contains amounts in cents (e.g., amount:12300 for a user-entered amount:123).

    Later, getSanitizedRawFilters processes rawQuery and calls getUpdatedFilterValue at line 707 without a shouldSkipAmountConversion flag, so it calls convertToBackendAmount(12300) → 1230000. This double conversion (×100 twice) causes the displayed amount to show 12300 instead of 123.

    The same issue exists in SearchPageHeaderInput.tsx:191-206. The SearchRouter path is unaffected because it doesn't pass rawQuery.

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

    In useSearchPageInput.tsx and SearchPageHeaderInput.tsx, don't pass rawQuery when shouldSkipAmountConversion is true (i.e., when the query already has backend-format amounts). The rawQuery param exists to preserve the user's original typed input for display — recent searches don't need it since their amounts are already converted.

    Change from:

    rawQuery: queryWithSubstitutions
    

    to:

    rawQuery: shouldSkipAmountConversion ? undefined : queryWithSubstitutions
    

    What alternative solutions did you explore? (Optional)

    An alternative would be to thread a shouldSkipAmountConversion parameter through getSanitizedRawFilters → getUpdatedFilterValue. This is more invasive and less clean — the simpler fix is to not pass rawQuery when the query is already in backend format, since rawQuery is only meant for preserving user-typed input.

    Investigation details

    Data flow (bug scenario):

    1. User searches amount:123 → converted to amount:12300 (cents) in q URL param
    2. Stored as type:expense amount:12300 in nvp_recentSearches
    3. User clicks recent search from search page header
    4. submitSearch("amount:12300", true) — shouldSkipAmountConversion=true
    5. updatedQuery = "amount:12300" (correct, conversion skipped)
    6. rawQuery = "amount:12300" (already in cents — this is the bug)
    7. getSanitizedRawFilters processes rawQuery, calling convertToBackendAmount(12300) = 1230000
    8. Display shows amount:12300 instead of amount:123

    Key files:

    • src/components/Search/SearchPageHeader/useSearchPageInput.tsx:128 — passes rawQuery
    • src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx:204 — same issue
    • src/libs/SearchQueryUtils.ts:707 — unconditional conversion in getSanitizedRawFilters
    • src/libs/CurrencyUtils.ts:71-73 — convertToBackendAmount multiplies by 100

    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 Apr 7, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Apr 7, 2026
  5. melvin-bot commented on Apr 7, 2026

    @melvin-bot

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

  6. changed the title [-]Extra two significant figures are added to amount when searched from Recent searches[/-] [+][$250] Extra two significant figures are added to amount when searched from Recent searches[/+] on Apr 7, 2026
  7. melvin-bot commented on Apr 7, 2026

    @melvin-bot
  8. Abdullahtmk commented on Apr 7, 2026

    @Abdullahtmk

    Proposal

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

    When a user selects a recent search like type:expense amount:123, the amount should remain 123 in the query UI. Instead, after selecting the recent search, it becomes 12300

    What is the root cause of that problem?

    Recent searches are displayed with a user-readable label, but the selected query uses the stored backend query (amount already in minor units).
    Then amount normalization is applied again in the query parsing flow.

    In SearchAutocompleteList, recent-search items are built like this:

    const recentSearchesData = sortedRecentSearches?.slice(0, 5).map(([recentSearchHash, {query}]) => {
    const searchQueryJSON = buildSearchQueryJSON(query);
    return {
    text: searchQueryJSON
    ? buildUserReadableQueryString({
    queryJSON: searchQueryJSON,
    PersonalDetails: personalDetails,
    reports,
    taxRates,
    cardList: allCards,
    cardFeeds: allFeeds,
    policies,
    currentUserAccountID,
    autoCompleteWithSpace: false,
    translate,
    feedKeysWithCards,
    reportAttributes,
    })
    : query,
    singleIcon: expensifyIcons.History,
    searchQuery: query,

    When selected, submitSearch() runs with that searchQuery:

    } else if (item.searchItemType === CONST.SEARCH.SEARCH_ROUTER_ITEM_TYPE.SEARCH) {
    submitSearch(item.searchQuery, item.keyForList !== CONST.SEARCH.SEARCH_ROUTER_ITEM_TYPE.FIND_ITEM);

    And amount filters are normalized in SearchQueryUtils (convertToBackendAmount), which causes repeated scaling effects in this path:

    function getUpdatedFilterValue(filterName: ValueOf<typeof CONST.SEARCH.SYNTAX_FILTER_KEYS>, filterValue: string | string[], shouldSkipAmountConversion = false) {
    if (AMOUNT_FILTER_KEYS.includes(filterName as SearchAmountFilterKeys)) {
    if (shouldSkipAmountConversion) {
    return filterValue;
    }
    if (typeof filterValue === 'string') {
    const backendAmount = convertToBackendAmount(Number(filterValue));
    return Number.isNaN(backendAmount) ? filterValue : backendAmount.toString();
    }
    return filterValue.map((amount) => {
    const backendAmount = convertToBackendAmount(Number(amount));
    return Number.isNaN(backendAmount) ? amount : backendAmount.toString();
    });

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

    Make recent-search selection submit the user-readable query string (the same one shown in UI), not the raw stored backend query. That ensures one consistent conversion path and keeps visible amount stable.

    Change this

    const recentSearchesData = sortedRecentSearches?.slice(0, 5).map(([recentSearchHash, {query}]) => {
    const searchQueryJSON = buildSearchQueryJSON(query);
    return {
    text: searchQueryJSON
    ? buildUserReadableQueryString({
    queryJSON: searchQueryJSON,
    PersonalDetails: personalDetails,
    reports,
    taxRates,
    cardList: allCards,
    cardFeeds: allFeeds,
    policies,
    currentUserAccountID,
    autoCompleteWithSpace: false,
    translate,
    feedKeysWithCards,
    reportAttributes,
    })
    : query,
    singleIcon: expensifyIcons.History,
    searchQuery: query,
    keyForList: recentSearchHash,
    searchItemType: CONST.SEARCH.SEARCH_ROUTER_ITEM_TYPE.SEARCH,
    };
    });

    To this

    // App/src/components/Search/SearchAutocompleteList.tsx
    
    const recentSearchesData = sortedRecentSearches?.slice(0, 5).map(([recentSearchHash, {query}]) => {
        const searchQueryJSON = buildSearchQueryJSON(query);
    
        const readableQuery = searchQueryJSON
            ? buildUserReadableQueryString({
                  queryJSON: searchQueryJSON,
                  PersonalDetails: personalDetails,
                  reports,
                  taxRates,
                  cardList: allCards,
                  cardFeeds: allFeeds,
                  policies,
                  currentUserAccountID,
                  autoCompleteWithSpace: false,
                  translate,
                  feedKeysWithCards,
                  reportAttributes,
              })
            : query;
    
        return {
            text: readableQuery,
            singleIcon: expensifyIcons.History,
            searchQuery: readableQuery, // use readable query for selection path
            keyForList: recentSearchHash,
            searchItemType: CONST.SEARCH.SEARCH_ROUTER_ITEM_TYPE.SEARCH,
        };
    });
    

    Optional hardening (if needed): for recent-search items, pass shouldSkipAmountConversion = false explicitly in the submit path, so readable amounts are converted exactly once.

    What alternative solutions did you explore? (Optional)

    Change buildSearchQueryJSON(rawQuery) sanitization to skip amount conversion for raw query inputs but its too broad/risky because it affects many search entry points. Secondly, you could keep using stored raw query but add explicit “already backend amount” detection. However this is Error-prone and ambiguous, especially across currencies/formatting.
    Lastly, another thing you could do is Store both raw and readable recent-query variants in Onyx. But it is more invasive state/schema change than needed for this bug.

  9. wildan-m commented on Apr 7, 2026

    @wildan-m
    Contributor

    Proposal

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

    When a user clicks a recent search containing an amount filter (e.g., type:expense amount:123), the displayed amount gets multiplied by 100 — showing amount:12300 instead of amount:123.

    What is the root cause of that problem?

    Recent searches are stored in nvp_recentSearches with amounts already in backend format (cents). For example, a user search of amount:123 is stored as amount:12300. When the user clicks on this recent search from the search page header, submitSearch is invoked with shouldSkipAmountConversion = true, which correctly prevents getQueryWithUpdatedValues from converting the amount a second time for the query URL param. However, submitSearch unconditionally passes the same value as rawQuery:

    Navigation.navigate(
    ROUTES.SEARCH_ROOT.getRoute({
    query: updatedQuery,
    rawQuery: queryWithSubstitutions,
    }),

    The same pattern exists in the desktop variant:

    Navigation.navigate(
    ROUTES.SEARCH_ROOT.getRoute({
    query: updatedQuery,
    rawQuery: queryWithSubstitutions,
    }),

    When the search page processes this route, buildSearchQueryJSON receives the rawQuery and passes it through getRawFilterListFromQuery → getSanitizedRawFilters → getUpdatedFilterValue:

    if (isRecognizedFilterKey) {
    updatedValue = getUpdatedFilterValue(filterKey as ValueOf<typeof CONST.SEARCH.SYNTAX_FILTER_KEYS>, updatedValue);

    This call to getUpdatedFilterValue does NOT receive a shouldSkipAmountConversion flag, so it defaults to false and calls convertToBackendAmount on the already-backend-format value 12300, producing 1230000. The resulting rawFilterList is then used by buildUserReadableQueryString to render the query in the search input, where convertToFrontendAmountAsInteger(1230000) yields 12300 instead of the expected 123.

    The SearchRouter path is unaffected because it does not pass rawQuery at all:

    Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query: updatedQuery}));

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

    In both useSearchPageInput.tsx and SearchPageHeaderInput.tsx, conditionally omit rawQuery when shouldSkipAmountConversion is true. The rawQuery parameter exists to preserve the user's original typed input for display purposes — recent searches have no user-typed input to preserve since their values are already in backend format.

    When rawQuery is omitted, buildSearchQueryJSON falls back to deriving the filter list from the main query param, and buildUserReadableQueryString uses the flatFilters path which correctly converts backend amounts to frontend display via convertToFrontendAmountAsInteger.

    In submitSearch of both files, change:

    rawQuery: queryWithSubstitutions,
    

    to:

    rawQuery: shouldSkipAmountConversion ? undefined : queryWithSubstitutions,
    

    What alternative solutions did you explore? (Optional)

    I considered threading a shouldSkipAmountConversion parameter through getRawFilterListFromQuery → getSanitizedRawFilters → getUpdatedFilterValue so that the raw filter processing could skip amount conversion when appropriate. While this preserves the rawFilterList (which maintains the user's original filter ordering), it requires modifying three function signatures in SearchQueryUtils.ts for a problem that only manifests when rawQuery carries backend-format data — a scenario the rawQuery parameter was never designed for. The simpler approach of omitting rawQuery when no user-typed input exists is both minimal and semantically correct.

    I also explored converting the recent search queries from backend to user-readable format before submission (using the already-computed readable text in SearchAutocompleteList). This would break non-amount filters like from/to/payer — getUpdatedFilterValue expects emails for these filters and converts them to account IDs, but the readable text contains display names instead, causing the lookup to fail silently.

    Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/87285-fix-recent-search-amount?expand=1

  10. github-actions commented on Apr 7, 2026

    @github-actions
    Contributor

    ⚠️ @wildan-m 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.

  11. abbasifaizan70 commented on Apr 7, 2026

    @abbasifaizan70
    Contributor

    Proposal

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

    When a user selects a recent search like type:expense amount:123, the amount should remain 123 in the query UI. Instead, after selecting the recent search, it becomes 12300

    What is the root cause of that problem?

    When a recent-search item is selected, the query is already normalized for backend use, but we were still forwarding that same value as rawQuery. That lets the raw-query display path re-interpret normalized amount values and makes amount:123 show up as amount:12300.

    submitSearch(item.searchQuery, item.keyForList !== CONST.SEARCH.SEARCH_ROUTER_ITEM_TYPE.FIND_ITEM);

    Recent-search selections are sent with shouldSkipAmountConversion=true, meaning the selected query is already normalized.
    submitSearch(item.searchQuery, item.keyForList !== CONST.SEARCH.SEARCH_ROUTER_ITEM_TYPE.FIND_ITEM);

    Same behavior in the shared search-page hook, so the issue exists in both header entry paths.

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

    rawQuery: shouldSkipAmountConversion ? undefined : queryWithSubstitutions,

    rawQuery: queryWithSubstitutions,

    rawQuery: shouldSkipAmountConversion ? undefined : queryWithSubstitutions,

    Demo

    Screen.Recording.2026-04-08.at.2.04.29.AM.mov
  12. wildan-m commented on Apr 7, 2026

    @wildan-m
    Contributor

    @ProposalPolice This proposal is not a duplicate. The two proposals target completely different files and use different fix mechanisms:

    • My proposal modifies useSearchPageInput.tsx and SearchPageHeaderInput.tsx — conditionally omitting rawQuery when shouldSkipAmountConversion is true, preventing the double conversion in getSanitizedRawFilters.
    • The other proposal modifies SearchAutocompleteList.tsx — changing searchQuery from the stored backend query to the user-readable text.

    These are distinct approaches at different layers of the codebase. Furthermore, the other approach of submitting the readable query string would break from/ to / payer filters, because getUpdatedFilterValue expects emails to convert to account IDs via getPersonalDetailByEmail(), but the readable text contains display names instead.

  13. 120 remaining items

  14. thesahindia commented on May 11, 2026

    @thesahindia
    Member

    BugZero Checklist:

    Regression Test Proposal Template

    Regression Test Proposal

    Test:

    1. Go to Spend
    2. Search "amount:1"
    3. Clear the search field and click outside to remove the focus
    4. Click on the search field
    5. Click "type:expense amount:1" from recent searches
    6. Verify the amount doesn't change to 100 in search

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-4813-ae99-2370-fba5c81e01e4
  15. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on May 11, 2026
  16. melvin-bot commented on May 14, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  17. melvin-bot commented on May 15, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/2041622122830675700/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  18. mallenexpensify commented on May 18, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @thesahindia due $250 via NewDot

    ^ Test case created

  19. garrettmknight commented on Jul 28, 2026

    @garrettmknight
    Contributor

    $250 approved for @thesahindia

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