Skip to content

[$250] Reports - Violation is not visible on preview on "Reports" if expenses are held offline. #76816

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.2.72-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: #74541
Email or phone of affected tester (no customers): ibellicotest+2154@gmail.com
Issue reported by: Applause Internal Team
Device used: Motorola MotoG60 / Android 12 / Chrome ( mWeb / Hybrid app) - Windows 11 / Chrome
App Component: Search

Action Performed:

Prerequisite: Account has at least one workspace.

  1. Open the Expensify app.
  2. Navigate to “Reports” > “Reports” (so page is already loaded for next steps)
  3. Open any workspace chat.
  4. Create two manual expenses.
  5. Turn off internet connection.
  6. Open the report of the just created expenses.
  7. Long tap and select both expenses.
  8. Tap on the dropdown menu and select "Hold"
  9. Enter any reason and hold the expenses.
  10. Note that a "This expense was put on hold" message appears on both previews.
  11. Navigate to "Reports" > "Reports"
  12. Note that report preview doesn´t show any violation.
  13. Turn on internet connection.
  14. Note that violation is still not visible.
  15. Open report and return.
  16. Note that violation is still not visible.
  17. Navigate to "Inbox" and return to "Reports".
  18. Note that violation is now displayed on report preview.

Expected Result:

When expenses are held while in offline mode, violation should be automatically visible on expenses preview on chat and also on "Reports".

Actual Result:

When expenses are held while in offline mode, violation is not visible on report preview on "Reports". Violation is still not visible when user returns to online mode. User has to navigate to "Inbox" and return to "Reports" to make the violation appear on report preview.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7021139_1764889562673.V.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022001079686997417329
  • Upwork Job ID: 2001079686997417329
  • Last Price Increase: 2025-12-30
  • Automatic offers:
    • cretadn22 | Contributor | 110014406
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Dec 5, 2025
  2. melvin-bot commented on Dec 5, 2025

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (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. ashu75575 commented on Dec 6, 2025

    @ashu75575
    Contributor

    Proposal

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

    When expenses are put on hold while in offline mode from a workspace chat, the violation indicator doesn't appear on the report preview in the "Reports" page. The violation remains hidden even after reconnecting to the internet. Users must navigate to "Inbox" and back to "Reports" for the violation to finally appear.


    What is the root cause of that problem?

    The Reports page displays data from a cached search snapshot stored in Onyx. When we hold expenses, there are two different code paths:

    1. General search flow - Uses holdMoneyRequestOnSearch() which properly updates the search snapshot
    2. Workspace chat flow - Uses putTransactionsOnHold() which does NOT update the search snapshot

    The bug occurs in the workspace chat flow:

    When holding expenses from a workspace chat (route: SCREENS.SEARCH.MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS), the code calls putTransactionsOnHold():

    // SearchHoldReasonPage.tsx - Line ~27
    if (route.name === SCREENS.SEARCH.MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS) {
        putTransactionsOnHold(context.selectedTransactionIDs, comment, reportID);
        context.clearSelectedTransactions(true);
    }

    This function updates the transaction violations in Onyx, but doesn't update the search snapshot. The Reports page continues reading from the stale snapshot cache, so the violation never appears until something else triggers a refresh (like navigating to Inbox).


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

    Solution: Use holdMoneyRequestOnSearch() for both flows, since both routes are in the search context and need the snapshot updated.

    Change in SearchHoldReasonPage.tsx (around line 27):

    Before:

    const onSubmit = useCallback(
        ({comment}: FormOnyxValues<typeof ONYXKEYS.FORMS.MONEY_REQUEST_HOLD_FORM>) => {
            if (route.name === SCREENS.SEARCH.MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS) {
                putTransactionsOnHold(context.selectedTransactionIDs, comment, reportID);
                context.clearSelectedTransactions(true);
            } else {
                holdMoneyRequestOnSearch(context.currentSearchHash, Object.keys(context.selectedTransactions), comment, allTransactions, allReportActions);
                context.clearSelectedTransactions();
            }
    
            Navigation.goBack();
        },
        [route.name, context, reportID, allTransactions, allReportActions],
    );

    After:

    const onSubmit = useCallback(
        ({comment}: FormOnyxValues<typeof ONYXKEYS.FORMS.MONEY_REQUEST_HOLD_FORM>) => {
            // Use holdMoneyRequestOnSearch for both flows to ensure snapshot is updated
            holdMoneyRequestOnSearch(
                context.currentSearchHash,
                route.name === SCREENS.SEARCH.MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS 
                    ? context.selectedTransactionIDs 
                    : Object.keys(context.selectedTransactions),
                comment,
                allTransactions,
                allReportActions
            );
            context.clearSelectedTransactions(route.name === SCREENS.SEARCH.MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS);
    
            Navigation.goBack();
        },
        [route.name, context, allTransactions, allReportActions],
    );

    Additional change in libs/actions/Search.ts - holdMoneyRequestOnSearch() function:

    Currently, holdMoneyRequestOnSearch() only updates the child action count but doesn't add optimistic violation updates. We need to add the violation to show the UI changes immediately while offline:

    function holdMoneyRequestOnSearch(hash: number, transactionIDList: string[], comment: string, allTransactions: OnyxCollection<Transaction>, allReportActions: OnyxCollection<ReportActions>) {
        const {optimisticData, finallyData} = getOnyxLoadingData(hash);
        
        transactionIDList.forEach((transactionID) => {
            const transaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
            const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transaction?.reportID}`] ?? {};
            const iouReportAction = getIOUActionForTransactionID(Object.values(reportActions ?? {}), transactionID);
            
            if (iouReportAction) {
                optimisticData.push({
                    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transaction?.reportID}`,
                    onyxMethod: Onyx.METHOD.MERGE,
                    value: {
                        [iouReportAction.reportActionID]: {
                            childVisibleActionCount: (iouReportAction?.childVisibleActionCount ?? 0) + 1,
                        },
                    },
                });
            }
    
            // Add optimistic violation update for immediate UI feedback
            const transactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`] ?? [];
            const newViolation = {name: CONST.VIOLATIONS.HOLD, type: CONST.VIOLATION_TYPES.VIOLATION, showInReview: true};
            const updatedViolations = [...transactionViolations, newViolation];
            
            optimisticData.push({
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`,
                value: updatedViolations,
            });
    
            // Add pending action for grayed-out UI
            optimisticData.push({
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
                value: {
                    pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
                },
            });
    
            // Update snapshot to show violation in Reports page
            optimisticData.push({
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${hash}`,
                value: {
                    data: {
                        [`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`]: updatedViolations,
                    },
                },
            } as OnyxUpdate);
        });
    
        API.write(WRITE_COMMANDS.HOLD_MONEY_REQUEST_ON_SEARCH, {hash, transactionIDList, comment}, {optimisticData, finallyData});
    }

    Note: You'll need to ensure allTransactionViolations is accessible in this function (either passed as a parameter or imported).


    What alternative solutions did you explore?

    N/A

  4. imadirtydog commented on Dec 6, 2025

    @imadirtydog

    Proposal

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

    Violation is not visible on preview on "Reports" if expenses are held offline. #76816

    What is the root cause of that problem?

    When we hold the expense offline, the search snapshot does not get updated with the violation.

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

    We could update the snapshot optimistically around here

     if (currentSearchQueryJSON?.hash) {
            // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830
            optimisticData.push({
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${currentSearchQueryJSON.hash}`,
                value: {
                    data: {
                        [`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`]: updatedViolations,
                    },
                },
            });
        }
    
    

    We could also apply similar logic to unholdRequest, mergeDuplicates, resolveDuplicates etc.

    What alternative solutions did you explore? (Optional)

    It could be possible to pull in violation data straight from onyx in

    function ExpenseReportListItem<TItem extends ListItem>({
    instead of relying on snapshot data for violations, but I think this would be pretty wasteful.

    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.

  5. mallenexpensify commented on Dec 9, 2025

    @mallenexpensify
    Contributor

    Can't stop thinking about how 'batching' or 'bucketing' related issues could help fix them more efficiently, espec for offline-related issues (and... ones that are edge cases).
    I think it might be a better approach than just closing them (or... fixing one-off too).
    More soon....

  6. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Dec 16, 2025
  7. changed the title [-]Reports - Violation is not visible on preview on "Reports" if expenses are held offline.[/-] [+][$250] Reports - Violation is not visible on preview on "Reports" if expenses are held offline.[/+] on Dec 16, 2025
  8. melvin-bot commented on Dec 16, 2025

    @melvin-bot
  9. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Dec 16, 2025
  10. 31 remaining items

  11. ZhenjaHorbach commented on Jan 16, 2026

    @ZhenjaHorbach
    Contributor

    The PR is in prod
    The regression period will end on January 20

  12. ZhenjaHorbach commented on Jan 20, 2026

    @ZhenjaHorbach
    Contributor

    BugZero Checklist:

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

      Unfortunately, I did not find a suitable PR

    • [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: NA

    • [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.

    Regression Test Proposal

    Test:

    1. Open the Expensify app.
    2. Navigate to “Reports” > “Reports” (so page is already loaded for next steps)
    3. Open any workspace chat.
    4. Create two manual expenses.
    5. Turn off internet connection.
    6. Open the report of the just created expenses.
    7. Long tap and select both expenses.
    8. Tap on the dropdown menu and select "Hold"
    9. Enter any reason and hold the expenses.
    10. Note that a "This expense was put on hold" message appears on both previews.
    11. Navigate to "Reports" > "Reports"
    12. Report preview show violations.

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-e44c-aeb4-dafb-cab0c70b4a94
  13. ZhenjaHorbach commented on Jan 20, 2026

    @ZhenjaHorbach
    Contributor

    @mallenexpensify
    We are ready for payment!

  14. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed
    ReviewingHas a PR in review
    on Jan 21, 2026
  15. mallenexpensify commented on Jan 21, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @cretadn22 paid $250 via Upwork
    Contributor+: @ZhenjaHorbach due $250 via NewDot

    ^ Test case created

    Thx!

  16. garrettmknight commented on Jan 21, 2026

    @garrettmknight
    Contributor

    $250 approved for @ZhenjaHorbach

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