Skip to content

[PAY NOW / CHECKLIST][$250] Report - Infinite loading when creating report offline on workspace for the first time. #72382

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: 9.2.29-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: https://test-management.browserstack.com/projects/2219752/test-runs/TR-1236/folder/13176730/41237110/945415790
Email or phone of affected tester (no customers): ibellicotest+1908@gmail.com
Issue reported by: Applause Internal Team
Device used: Motorola MotoG60 / Android 12 / Chrome ( mWeb / Hybrid app) - Windows 11 / Chrome
App Component: Money Requests

Action Performed:

Prerequisite: Account has no workspaces yet

  1. Open the Expensify app.
  2. Tap on FAB and create a workspace.
  3. Return to "Inbox"
  4. Turn off internet connection.
  5. Tap on FAB and create a new report.
  6. Tap on the back button on the top left corner to return to "Inbox" again.
  7. Open workspace chat.
  8. Note that the preview of the just created report, displays infinite loading.

Expected Result:

Preview of report created while offline, should load correctly and show a "This report has no expenses" message.

Actual Result:

When creating a report while offline on workspace for the first time, preview of report shows infinite loading.

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

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021977875728430112256
  • Upwork Job ID: 1977875728430112256
  • Last Price Increase: 2025-10-27
  • Automatic offers:
    • abzokhattab | Contributor | 109293667

Activity

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

    @melvin-bot

    Triggered auto assignment to @jliexpensify (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. abzokhattab commented on Oct 11, 2025

    @abzokhattab
    Contributor

    Proposal

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

    Report previews show infinite loading when creating a report offline on a workspace for the first time, instead of displaying "This report has no expenses".

    What is the root cause of that problem?

    • When a workspace is created, the workspace chat report is created but its metadata is never initialized with hasOnceLoadedReportActions
    • The MoneyRequestReportPreviewContent component determines whether to show loading based on this condition:
      const shouldShowLoading = !chatReportMetadata?.hasOnceLoadedReportActions && transactions.length === 0 && !chatReportMetadata?.isOptimisticReport;
    • When creating a report offline, the expense report metadata gets properly set, but the parent workspace chat metadata remains uninitialized
    • This causes hasOnceLoadedReportActions to remain undefined, keeping the loading indicator visible indefinitely

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

    In Report.ts, update the buildNewReportOptimisticData function here to set hasOnceLoadedReportActions: true for the parent report when adding the report preview action

    {
        onyxMethod: Onyx.METHOD.MERGE,
        key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${parentReport?.reportID}`,
        value: {
            hasOnceLoadedReportActions: true,
        },
    }
    • This ensures the workspace chat metadata is properly initialized when the first report is created

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    • Verify that when a new report is created on a workspace, the parent workspace chat metadata is set with hasOnceLoadedReportActions: true
    test code
        it('should set hasOnceLoadedReportActions for parent report metadata when creating a new report', async () => {
            const accountID = 1234;
            const policyID = '5678';
            const mockFetchData = fetch as MockFetch;
            const policy = {
                ...createRandomPolicy(Number(policyID)),
                isPolicyExpenseChatEnabled: true,
                type: CONST.POLICY.TYPE.TEAM,
                harvesting: {
                    enabled: false,
                },
            };
            await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, policy);
    
            mockFetchData.pause();
            Report.createNewReport({accountID}, true, false, policyID);
            const parentReport = ReportUtils.getPolicyExpenseChat(accountID, policyID);
    
            await new Promise<void>((resolve) => {
                const connection = Onyx.connect({
                    key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${parentReport?.reportID}`,
                    callback: (metadata) => {
                        if (metadata?.hasOnceLoadedReportActions) {
                            Onyx.disconnect(connection);
                            expect(metadata.hasOnceLoadedReportActions).toBe(true);
                            resolve();
                        }
                    },
                });
            });
        });

    What alternative solutions did you explore? (Optional)

    NA

  4. paulnjs commented on Oct 11, 2025

    @paulnjs
    Contributor

    Proposal

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

    When creating a report while offline on workspace for the first time, preview of report shows infinite loading.

    What is the root cause of that problem?

    • Condition to show the loading indicator in report preview is:

    const shouldShowLoading = !chatReportMetadata?.hasOnceLoadedReportActions && transactions.length === 0 && !chatReportMetadata?.isOptimisticReport;

    • In this case, it is true because !chatReportMetadata?.hasOnceLoadedReportActions is false.

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

    • When we create a new workspace, the chatReportMetadata?.hasOnceLoadedReportActions should be true for each policy expense chat created.
      We can set it to true in:
      {
      onyxMethod: Onyx.METHOD.MERGE,
      key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${expenseChatReportID}`,
      value: {
      isOptimisticReport: true,
      },
      },

      or in success data.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    NA

    What alternative solutions did you explore? (Optional)

  5. coderyak commented on Oct 12, 2025

    @coderyak
    Contributor

    Proposal

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

    When creating a report offline on a workspace for the first time, the report preview in the workspace chat displays an infinite loading spinner instead of showing "This report has no expenses".

    What is the root cause of that problem?

    The root cause is missing metadata for the parent workspace chat when creating a new IOU report.

    The loading logic in MoneyRequestReportPreviewContent.tsx checks:

    const shouldShowLoading = !chatReportMetadata?.hasOnceLoadedReportActions && 
                              transactions.length === 0 && 
                              !chatReportMetadata?.isOptimisticReport;

    When creating a report on a new workspace for the first time:

    1. The IOU report's metadata is set with hasOnceLoadedReportActions: true in buildNewReportOptimisticData()
    2. However, the parent workspace chat's metadata is not set at all
    3. This causes chatReportMetadata to be undefined
    4. All three conditions in the loading check evaluate to true, triggering infinite loading

    The issue doesn't occur on existing workspaces because those workspace chats already have hasOnceLoadedReportActions: true from previous openReport() calls.

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

    In src/libs/actions/Report.ts, update the buildNewReportOptimisticData() function to set metadata for the parent workspace chat:

    Add this to the optimisticData array (around line 2801):

    {
        onyxMethod: Onyx.METHOD.MERGE,
        key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${parentReport?.reportID}`,
        value: {
            isOptimisticReport: true,
            hasOnceLoadedReportActions: true,
        },
    }

    This ensures the workspace chat is marked as having loaded its actions (even if empty), preventing the loading spinner from showing when transactions are zero.

    What alternative solutions did you explore? (Optional)

    Alternative 1: Set only hasOnceLoadedReportActions: true without isOptimisticReport: true.
    This would work technically, but setting both flags is more consistent with patterns used elsewhere in the codebase (e.g., buildOnyxDataForMoneyRequest() in IOU.ts) and provides better semantic clarity.

  6. melvin-bot commented on Oct 12, 2025

    @melvin-bot

    📣 @coderyak! 📣
    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>
    
  7. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Oct 13, 2025
  8. changed the title [-]Report - Infinite loading when creating report offline on workspace for the first time.[/-] [+][$250] Report - Infinite loading when creating report offline on workspace for the first time.[/+] on Oct 13, 2025
  9. melvin-bot commented on Oct 13, 2025

    @melvin-bot
  10. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 13, 2025
  11. melvin-bot commented on Oct 13, 2025

    @melvin-bot

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

  12. 25 remaining items

  13. abzokhattab commented on Oct 30, 2025

    @abzokhattab
    Contributor

    PR is ready! #73885

    cc @eh2077

  14. abzokhattab commented on Nov 13, 2025

    @abzokhattab
    Contributor

    It looks like the automation failed here.. the PR was merged more than 2 weeks ago

  15. jliexpensify commented on Nov 13, 2025

    @jliexpensify
    Contributor

    Thanks @abzokhattab - looking.

  16. jliexpensify commented on Nov 13, 2025

    @jliexpensify
    Contributor

    Correct, deployed to prod Nov 4th so ready for payment.

    @eh2077 checklist please!

  17. changed the title [-][$250] Report - Infinite loading when creating report offline on workspace for the first time.[/-] [+][PAY NOW / CHECKLIST][$250] Report - Infinite loading when creating report offline on workspace for the first time.[/+] on Nov 13, 2025
  18. jliexpensify commented on Nov 13, 2025

    @jliexpensify
    Contributor

    Upworks job paid and closed @abzokhattab

  19. jliexpensify commented on Nov 13, 2025

    @jliexpensify
    Contributor

    Payment Summary

    • C: @abzokhattab $250 (to be paid via Upworks)
    • C+: @eh2077 $250 (to be paid via New Expensify requests) - waiting on checklist

    Upwork job

  20. jliexpensify commented on Nov 16, 2025

    @jliexpensify
    Contributor

    Bump @eh2077 for checklist plzzzz

  21. eh2077 commented on Nov 17, 2025

    @eh2077
    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.

      Link to comment: NA. I can't figure out the exact PR that is directly related to this bug. This is an edge case though.

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

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

      Link to issue:

    Regression Test Proposal

    Precondition:

    • Account has no workspaces yet

    Test:

    1. Open the Expensify app.
    2. Tap on FAB and create a workspace.
    3. Return to "Inbox"
    4. Turn off internet connection.
    5. Tap on FAB and create a new report.
    6. Tap on the back button on the top left corner to return to "Inbox" again.
    7. Open workspace chat.
    8. Validate that the report preview displays correctly without infinite loading

    Do we agree 👍 or 👎

  22. eh2077 commented on Nov 17, 2025

    @eh2077
    Contributor

    @jliexpensify Checklist done, thanks!

  23. garrettmknight commented on Nov 21, 2025

    @garrettmknight
    Contributor

    $250 approved for @eh2077

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in reviewWeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions