Skip to content

[$250] Reports - Workspace filter results shows blank space in the middle of the page. #83991

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.28-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #81883
Email or phone of affected tester (no customers): dreamnitethedragon@gmail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Redminote 10S Android 13
App Component: User Settings

Action Performed:

  1. Launch app
  2. Create 2 Workspaces
  3. Create 5 expense in first workspace and 1 expense in second workspace
  4. Go to reports - filter - select workspace 1 and save search the results
  5. Delete the saved search
  6. Tap filter and select the same workspace and view results

Expected Result:

Workspace filter results must not show blank space in the middle of the page.

Actual Result:

Workspace filter results shows blank space in the middle of the page.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @dukenv0307
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022028727399074439102
  • Upwork Job ID: 2028727399074439102
  • Last Price Increase: 2026-04-07

Activity

  1. added
    Daily
    Bug
    on Mar 3, 2026
  2. melvin-bot commented on Mar 3, 2026

    @melvin-bot

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

  3. MobileMage commented on Mar 3, 2026

    @MobileMage
    Contributor

    Proposal

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

    When filtering reports by workspace and then repeating the filter after deleting a saved search, blank spaces appear in the middle of the results list. Items that should be gone are still occupying vertical space on screen.

    What is the root cause of that problem?

    Items with a pendingAction === 'delete' are passed into the sorted/rendered list but their content is hidden by OfflineWithFeedback. When hideChildren is true (online + DELETE pending + no errors), OfflineWithFeedback suppresses rendering the inner content but still returns its outer <View style={style}> wrapper — leaving behind a blank space the exact height of a list row.

    The check that computes visibleDataLength (to decide whether to show the empty state) correctly excludes DELETE-pending items:

    const visibleDataLength = filteredData.filter((item) => item.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || isOffline).length;
    if (shouldShowEmptyState(isDataLoaded, visibleDataLength, searchDataType)) {

    But that filtered count is only used for the empty-state guard. The items themselves are never filtered out of filteredData / sortedData before they are passed to the list — so they render as invisible rows with full height.

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

    Filter out DELETE-pending items from filteredData before they reach sortedData and the selection list. The right place is the filteredData memo (or immediately before sortedData is derived). Since isOffline should still let them show (for offline feedback UX), the same guard used elsewhere in the codebase applies: item.pendingAction !== DELETE || isOffline.

    const filteredData = useMemo(() => {
    if (!validGroupBy || isExpenseReportType) {
    return baseFilteredData;
    }
    const enriched = (baseFilteredData as TransactionGroupListItemType[]).map((item) => {
    const snapshot = item.transactionsQueryJSON?.hash ? groupByTransactionSnapshots[String(item.transactionsQueryJSON.hash)] : undefined;
    if (!snapshot?.data) {
    return item;
    }
    const [transactions1] = getSections({
    type: CONST.SEARCH.DATA_TYPES.EXPENSE,
    data: snapshot.data,
    currentAccountID: accountID,
    currentUserEmail: email ?? '',
    bankAccountList,
    translate,
    formatPhoneNumber,
    isActionLoadingSet,
    cardFeeds,
    allReportMetadata,
    cardList,
    });
    return {...item, transactions: transactions1 as TransactionListItemType[]};
    });
    return enriched;
    }, [
    validGroupBy,
    isExpenseReportType,
    baseFilteredData,
    groupByTransactionSnapshots,
    accountID,
    email,
    translate,
    formatPhoneNumber,
    isActionLoadingSet,
    cardFeeds,
    bankAccountList,
    allReportMetadata,
    cardList,
    ]);

         const filteredData = useMemo(() => {
             if (!validGroupBy || isExpenseReportType) {
    -            return baseFilteredData;
    +            return baseFilteredData.filter(
    +                (item) => item.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || isOffline,
    +            );
             }
    
             const enriched = (baseFilteredData as TransactionGroupListItemType[]).map((item) => {

    The same one-line filter should be applied to the non-grouped branch. This mirrors the existing pattern on line 1248 and ensures blank rows are never passed to the list renderer regardless of grouping mode.

    What alternative solutions did you explore? (Optional)

    An alternative would be to pass shouldHideOnDelete={false} through BaseListItem so that OfflineWithFeedback renders nothing (not even the outer View) when hiding — but that would require threading a new prop through several layers and could break offline strikethrough UX. Filtering at the data level before rendering is simpler and consistent with how the empty-state check already works.

  4. MelvinBot commented on Mar 3, 2026

    @MelvinBot
    Contributor

    Proposal

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

    After creating a saved search with a workspace filter, deleting that saved search, and then re-applying the same workspace filter, blank space appears in the middle of the search results page.

    What is the root cause of that problem?

    The root cause is that deleteSavedSearch() only cleans up ONYXKEYS.SAVED_SEARCHES but never invalidates the search result snapshot at ONYXKEYS.COLLECTION.SNAPSHOT${hash}. Since the same workspace filter deterministically produces the same query hash, re-applying the filter reads the stale snapshot immediately from Onyx instead of showing a loading skeleton.

    Here's the specific chain of events:

    1. User saves a search filtered by workspace 1 → results stored in snapshot_<H> (where H is the hash of the query)
    2. User deletes the saved search → deleteSavedSearch(H) only sets SAVED_SEARCHES[H] to null (Search.ts:364-398) — the snapshot at COLLECTION.SNAPSHOT${H} is left untouched
    3. User navigates to the default search (different hash) via useDeleteSavedSearch.tsx:31-35
    4. Deleting the saved search causes shouldCalculateTotals to flip from true to false (useSearchShouldCalculateTotals.ts:32) since isSavedSearch becomes false
    5. User re-applies the same workspace filter → same hash H is computed (deterministic hashing at SearchQueryUtils.ts:340-394)
    6. SearchContext reads COLLECTION.SNAPSHOT${H} via useOnyx → gets stale snapshot data immediately (SearchContext.tsx:88)
    7. isSearchDataLoaded returns true because the stale snapshot's type/status match the current query (SearchUIUtils.ts:3809-3819)
    8. The loading skeleton is not shown because shouldShowLoadingState requires data.length === 0 for an empty array, but the stale snapshot has data as a non-empty object (Search/index.tsx:399-405)
    9. Meanwhile, a new search API call triggers getOnyxLoadingData which uses Onyx.METHOD.MERGE to set isLoading: true — but never clears the data field (Search.ts:269-288)
    10. Additionally, shouldClearTotals is now true (from PR Fix stale Search footer totals by clearing count metadata on initial non-total fetch #81883's changes), so count: null, total: null, currency: null are merged into the snapshot metadata. Onyx's removeNestedNullValues removes these keys, creating an inconsistent state where the snapshot has data but no metadata
    11. The stale snapshot data, combined with potentially outdated metadata, is rendered by getSections / getTransactionsSections — and items whose underlying Onyx data (transactions/reports) has changed since the snapshot was created may render as empty rows or produce layout gaps in the FlashList

    The codebase already acknowledges this race condition in a comment: "There's a race condition in Onyx which makes it return data from the previous Search" (Search/index.tsx:392-394), but the guard only checks type/status — which pass for the same filter.

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

    The fix should ensure that when a saved search is deleted and the same filter is re-applied, the stale snapshot doesn't cause rendering issues. There are two approaches:

    Option A (Recommended — clear snapshot on search re-trigger): In getOnyxLoadingData (Search.ts:260-319), when offset === 0 (indicating a fresh search, not pagination), use Onyx.METHOD.SET instead of Onyx.METHOD.MERGE for the snapshot, or explicitly clear the data field. This ensures that when a fresh search is triggered, stale data is cleared and the loading skeleton is shown until fresh results arrive.

    Option B (Targeted — clear snapshot on saved search deletion): In deleteSavedSearch (Search.ts:364-398), add optimistic data to clear the corresponding snapshot at ONYXKEYS.COLLECTION.SNAPSHOT${hash} (set it to null or clear its data field). This specifically handles the delete-then-refilter scenario.

    Option A is preferable because it addresses the broader issue of stale snapshots being rendered whenever the same hash is reused, not just after saved search deletion.

    What alternative solutions did you explore? (Optional)

    • Modifying isSearchDataLoaded to track freshness: Adding a timestamp or version counter to snapshots could detect staleness, but this adds complexity and doesn't address the core problem of stale data being rendered.
    • Clearing all snapshots on navigation: Too aggressive — would lose valid cached data for other searches.

    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  5. added
    External
    on Mar 3, 2026
  6. added
    Help Wanted
    on Mar 3, 2026
  7. melvin-bot commented on Mar 3, 2026

    @melvin-bot

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

  8. changed the title [-]Reports - Workspace filter results shows blank space in the middle of the page.[/-] [+][$250] Reports - Workspace filter results shows blank space in the middle of the page.[/+] on Mar 3, 2026
  9. melvin-bot commented on Mar 3, 2026

    @melvin-bot
  10. daledah commented on Mar 3, 2026

    @daledah
    Contributor

    Proposal

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

    Workspace filter results shows blank space in the middle of the page.

    What is the root cause of that problem?

    deleteSavedSearch() only cleans up ONYXKEYS.SAVED_SEARCHES but never invalidates the search result snapshot at ONYXKEYS.COLLECTION.SNAPSHOT${hash}.

    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.SAVED_SEARCHES}`,
    value: {
    [hash]: {
    pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
    },
    },
    },
    ];
    const successData: Array<OnyxUpdate<typeof ONYXKEYS.SAVED_SEARCHES>> = [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.SAVED_SEARCHES}`,
    value: {
    [hash]: null,
    },
    },
    ];
    const failureData: Array<OnyxUpdate<typeof ONYXKEYS.SAVED_SEARCHES>> = [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.SAVED_SEARCHES}`,
    value: {
    [hash]: {
    pendingAction: null,
    },
    },
    },
    ];
    API.write(WRITE_COMMANDS.DELETE_SAVED_SEARCH, {hash}, {optimisticData, failureData, successData});
    }

    When the user deletes a saved search and re-applies the same workspace filter, the same query hash is computed deterministically. The SearchContext reads the stale snapshot via useOnyx and returns it immediately.

    const [snapshotSearchResults] = useOnyx(`${ONYXKEYS.COLLECTION.SNAPSHOT}${searchContextData.currentSearchHash}`);

    isSearchDataLoaded returns true because the stale snapshot's type/status match the current query. getOnyxLoadingData uses Onyx.METHOD.MERGE and never clears the data field, so the old snapshot data is rendered and produces blank rows or layout gaps in the list.

    App/src/libs/SearchUIUtils.ts

    Lines 3809 to 3819 in 4f6bfe2

    function isSearchDataLoaded(searchResults: SearchResults | undefined, queryJSON: SearchQueryJSON | undefined) {
    const {status} = queryJSON ?? {};
    const sortedSearchResultStatus = !Array.isArray(searchResults?.search?.status)
    ? searchResults?.search?.status?.split(',').sort().join(',')
    : searchResults?.search?.status?.sort().join(',');
    const sortedQueryJSONStatus = Array.isArray(status) ? status.sort().join(',') : status;
    const isDataLoaded = searchResults?.data !== undefined && searchResults?.search?.type === queryJSON?.type && sortedSearchResultStatus === sortedQueryJSONStatus;
    return isDataLoaded;
    }

    function getOnyxLoadingData(
    hash: number,
    queryJSON?: SearchQueryJSON,
    offset?: number,
    isOffline?: boolean,
    isSearchAPI = false,
    shouldCalculateTotals?: boolean,
    ): OnyxData<typeof ONYXKEYS.COLLECTION.SNAPSHOT> {
    const shouldClearTotals = isSearchAPI && shouldCalculateTotals === false && offset === 0;
    const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.SNAPSHOT>> = [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${hash}`,
    value: {
    search: {
    ...(isSearchAPI && {isLoading: true}),
    ...(offset !== undefined ? {offset} : {}),
    ...(shouldClearTotals ? {count: null, total: null, currency: null} : {}),
    },
    },
    },
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${hash}`,
    value: {
    errors: null,
    },
    },
    ];

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

    In getOnyxLoadingData, when offset === 0 or offset === undefined (fresh search, not pagination) and isSearchAPI is true, explicitly set data: [] in the optimistic update so stale snapshot data is cleared before the new API request. This ensures the loading skeleton is shown until fresh results arrive.

    diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts
    index 1234567..abcdefg 100644
    --- a/src/libs/actions/Search.ts
    +++ b/src/libs/actions/Search.ts
    @@ -265,9 +265,11 @@ function getOnyxLoadingData(
     ): OnyxData<typeof ONYXKEYS.COLLECTION.SNAPSHOT> {
         const shouldClearTotals = isSearchAPI && shouldCalculateTotals === false && offset === 0;
    +    const isFreshSearch = isSearchAPI && (offset === 0 || offset === undefined);
         const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.SNAPSHOT>> = [
             {
                 onyxMethod: Onyx.METHOD.MERGE,
                 key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${hash}`,
                 value: {
    +                ...(isFreshSearch && {data: []}),
                     search: {
                         ...(isSearchAPI && {isLoading: true}),
                         ...(offset !== undefined ? {offset} : {}),

    What alternative solutions did you explore? (Optional)

    N/A

    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.

  11. dukenv0307 commented on Mar 3, 2026

    @dukenv0307
    Contributor

    @MelvinBot @daledah It seems like the issue can be reproduced on Android Native only. Can you please explain why?

  12. 30 remaining items

  13. melvin-bot commented on Mar 31, 2026

    @melvin-bot

    @dukenv0307 @brianlee-expensify this issue is now 4 weeks old, please consider:

    • Finding a contributor to fix the bug
    • Closing the issue if BZ has been unable to add the issue to a VIP or Wave project
    • If you have any questions, don't hesitate to start a discussion in #expensify-open-source

    Thanks!

  14. dukenv0307 commented on Apr 1, 2026

    @dukenv0307
    Contributor

    @jponikarchuk can you please close it?

  15. mvtglobally commented on Apr 4, 2026

    @mvtglobally

    Issue not reproducible during KI retests. (Third week)

  16. dukenv0307 commented on Apr 6, 2026

    @dukenv0307
    Contributor

    @jponikarchuk kindly bump to close the issue

  17. jponikarchuk commented on Apr 6, 2026

    @jponikarchuk
    Author

    @jponikarchuk kindly bump to close the issue

    @brianlee-expensify Could you please decide if this issue should be closed?

  18. melvin-bot commented on Apr 7, 2026

    @melvin-bot

    📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

  19. melvin-bot commented on Apr 9, 2026

    @melvin-bot

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

  20. removed
    Help Wanted
    on Apr 9, 2026
  21. brianlee-expensify commented on Apr 9, 2026

    @brianlee-expensify
    Contributor

    closing out as issue is no longer reproducible

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

Metadata

Metadata

Labels

BugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions