Skip to content

[$250] Reports - Workspace chat link opens workspace chat with wrong UI when opened from Reports #72792

Closed

Description

@lanitochka17

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.32-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: #72267
Email or phone of affected tester (no customers): djiofjnidfojdojoidfj@gmail.com
Issue reported by: Applause - Internal Team

Action Performed:

Precondition:

  • Account has a workspace
  1. Go to staging.new.expensify.com
  2. Open FAB > Create expense > Manual
  3. Submit an expense to any user (not workspace chat)
  4. Open the expense report
  5. Click More > Change workspace
  6. Select a workspace
  7. Go to Reports > Reports
  8. Open the expense report
  9. Click on the workspace link in "moved this report to the WORKSPACE LINK workspace"

Expected Result:

Workspace chat will open on Inbox because the link is a workspace chat link, not report link

Actual Result:

The workspace link opens the workspace chat on Reports, which leads to some abnormality that includes "This report has no expenses." in the workspace chat and the report preview appears as Comment section

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop
Platforms Tested: On which of our officially supported platforms was this issue tested:
  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Bug6976545_1760616103118.Screen_Recording_2025-10-16_at_19.51.33.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021979254999259299084
  • Upwork Job ID: 1979254999259299084
  • Last Price Increase: 2025-10-24
  • Automatic offers:
    • abzokhattab | Contributor | 109295214
Issue OwnerCurrent Issue Owner: @NicMendonca

Activity

  1. added
    Daily
    Bug
    on Oct 16, 2025
  2. melvin-bot commented on Oct 16, 2025

    @melvin-bot

    Triggered auto assignment to @NicMendonca (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 16, 2025

    @abzokhattab
    Contributor

    Proposal

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

    Workspace chat links opened from the Reports page incorrectly open in the Reports context instead of Inbox, causing UI issues like "This report has no expenses" appearing in workspace chats.

    What is the root cause of that problem?

    • The getReportURLForCurrentContext function generates URLs that preserve the current navigation context (Reports/Search)
    • When clicking a workspace chat link from the Reports page, the function returns a search-context URL for the workspace chat
    • Workspace chats are not designed to work in the Reports/Search context, which causes the UI abnormalities

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

    update the getReportURLForCurrentContext function:
    here

    • Retrieve the report data for the given reportID using getReportOrDraftReport
    • Check if the report is a workspace chat using isPolicyExpenseChat
    • If the report is a workspace chat, always return the standard Inbox route (ROUTES.REPORT_WITH_ID.getRoute(reportID)) regardless of the current navigation context
    • For non-workspace chats, maintain the existing behavior of preserving the search context when applicable
        const report = getReportOrDraftReport(reportID);
        const isWorkspaceChat = isPolicyExpenseChat(report);
    
        if (!isInSearchContext || isWorkspaceChat) {
            return `${environmentURL}/${ROUTES.REPORT_WITH_ID.getRoute(reportID)}`;
        }

    This ensures workspace chats always open in Inbox where they function correctly, while other reports continue to work as expected in the Reports page.

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

    update the getReportURLForCurrentContext test cases inside the ReportUtilsTest file to include a test for this case

           it('returns Inbox route for workspace chat even when in search context', async () => {
                // Create a workspace chat report
                const workspaceChatReportID = '999';
                const workspaceChat: Report = {
                    ...createRandomReport(999),
                    reportID: workspaceChatReportID,
                    chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
                    isOwnPolicyExpenseChat: true,
                    type: CONST.REPORT.TYPE.CHAT,
                };
    
                // Set up Onyx with the workspace chat
                await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${workspaceChatReportID}`, workspaceChat);
                await flushPromises();
    
                // Mock being in search context
                mockIsSearchTopmostFullScreenRoute.mockReturnValue(true);
                mockGetActiveRoute.mockReturnValue('search?q=type:report');
    
                // Even in search context, workspace chats should return Inbox route
                expect(getReportURLForCurrentContext(workspaceChatReportID)).toBe(`${environmentURL}/${ROUTES.REPORT_WITH_ID.getRoute(workspaceChatReportID)}`);
    
                // Clean up
                await Onyx.clear();
            });

    What alternative solutions did you explore? (Optional)

    NA

  4. added
    External
    on Oct 17, 2025
  5. changed the title [-]Reports - Workspace chat link opens workspace chat with wrong UI when opened from Reports[/-] [+][$250] Reports - Workspace chat link opens workspace chat with wrong UI when opened from Reports[/+] on Oct 17, 2025
  6. melvin-bot commented on Oct 17, 2025

    @melvin-bot
  7. added
    Help Wanted
    on Oct 17, 2025
  8. melvin-bot commented on Oct 17, 2025

    @melvin-bot

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

  9. ShridharGoel commented on Oct 19, 2025

    @ShridharGoel
    Contributor

    Proposal

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

    Workspace links inside the "moved this report to the WORKSPACE workspace" system message should open the workspace chat inside the Inbox view. Following that link after moving an expense report keeps the app on the Reports split view and shows a wrong UI.

    What is the root cause of that problem?

    getReportURLForCurrentContext always returns the search-context URL when the current route is search, even for workspace chats. When a user clicks the system message inside Reports, the navigation stays in that context and we render the workspace chat in the wrong pane.

    App/src/libs/ReportUtils.ts

    Lines 11975 to 12021 in 7165a14

    function getReportURLForCurrentContext(reportID: string | undefined): string {
    if (!reportID) {
    return `${environmentURL}/r/`;
    }
    const isInSearchContext = isSearchTopmostFullScreenRoute();
    if (!isInSearchContext) {
    return `${environmentURL}/${ROUTES.REPORT_WITH_ID.getRoute(reportID)}`;
    }
    // Navigation can return routes with a leading slash or missing when still mounting.
    // Normalize everything to match the path shape used by ROUTES helpers.
    const normalizeRoute = (route?: string) => {
    if (!route) {
    return undefined;
    }
    return route.startsWith('/') ? route.substring(1) : route;
    };
    const activeRoute = normalizeRoute(Navigation.getActiveRoute());
    let backToRoute: string | undefined;
    if (activeRoute) {
    const [, queryString = ''] = activeRoute.split('?');
    if (queryString) {
    const params = new URLSearchParams(queryString);
    const encodedBackTo = params.get('backTo');
    if (encodedBackTo) {
    // Prefer the backTo param when present; it points to the exact search state we left.
    backToRoute = normalizeRoute(decodeURIComponent(encodedBackTo));
    }
    }
    if (!backToRoute && activeRoute.startsWith(ROUTES.SEARCH_ROOT.route)) {
    // Otherwise keep the current search route (preserves tab + filters) as the return target.
    backToRoute = activeRoute;
    }
    }
    if (!backToRoute?.startsWith(ROUTES.SEARCH_ROOT.route)) {
    // Fall back to the generic search home when we can't recover a valid route.
    backToRoute = ROUTES.SEARCH_ROOT.route;
    }
    const relativePath = ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID, backTo: backToRoute});
    return `${environmentURL}/${relativePath}`;
    }

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

    Detect when the target report is a policyExpenseChat and bypass the search-specific route builder, updating navigation to the regular /r/:reportID route. This moves workspace chats into the central Inbox pane regardless of where the link was clicked.

    The updated code looks like this:

    function getReportURLForCurrentContext(reportID: string | undefined): string {
        if (!reportID) {
            return `${environmentURL}/r/`;
        }
        const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; // New
        const shouldBypassSearchContext = isPolicyExpenseChat(report); // New
    
        const isInSearchContext = isSearchTopmostFullScreenRoute();
        if (!isInSearchContext || shouldBypassSearchContext) { // Updated
            return `${environmentURL}/${ROUTES.REPORT_WITH_ID.getRoute(reportID)}`;
        }
    
        // .... existing code
    }

    We should also update tests/unit/ReportUtilsTest.ts to assert that policyExpenseChat links now bypass the search URL.

    New unit test can be added:

    it('opens workspace chats outside of the search context', async () => {
        const reportID = 'workspaceChatReportID';
        mockIsSearchTopmostFullScreenRoute.mockReturnValue(true);
        mockGetActiveRoute.mockReturnValue('search?q=type:report');
        await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {
            reportID,
            chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
        });
        await flushPromises();
        expect(getReportURLForCurrentContext(reportID)).toBe(`${environmentURL}/${ROUTES.REPORT_WITH_ID.getRoute(reportID)}`);
        await Onyx.clear();
    });
  10. bernhardoj commented on Oct 20, 2025

    @bernhardoj
    Contributor

    Proposal

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

    WS chat link from MOVED action message opens the WS chat within Reports page.

    What is the root cause of that problem?

    The MOVED action message is built from this function and the link is from getReportURLForCurrentContext.

    App/src/libs/ReportUtils.ts

    Lines 6524 to 6528 in cc0751e

    return translateLocal('iou.movedAction', {
    shouldHideMovedReportUrl: !isDM(report),
    movedReportUrl: getReportURLForCurrentContext(movedReportID),
    newParentReportUrl: getReportURLForCurrentContext(newParentReportID),
    toPolicyName,

    getReportURLForCurrentContext returns the URL depends on whether the user is on Reports tab or not. If true, then it will return the search money request report page URL.

    App/src/libs/ReportUtils.ts

    Lines 12019 to 12020 in cc0751e

    const relativePath = ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID, backTo: backToRoute});
    return `${environmentURL}/${relativePath}`;

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

    getReportURLForCurrentContext already does it job well, what we need is to remove the usage of getReportURLForCurrentContext when building the workspace URL (newParentReportUrl).

    App/src/libs/ReportUtils.ts

    Lines 6524 to 6528 in cc0751e

    return translateLocal('iou.movedAction', {
    shouldHideMovedReportUrl: !isDM(report),
    movedReportUrl: getReportURLForCurrentContext(movedReportID),
    newParentReportUrl: getReportURLForCurrentContext(newParentReportID),
    toPolicyName,

    newParentReportUrl: `${environmentURL}/${ROUTES.REPORT_WITH_ID.getRoute(newParentReportID)}`,
    

    For movedReportUrl, it will only be used if shouldHideMovedReportUrl is false, which is true inside the DM (when we move from DM to WS, the DM will also receive the MOVED action).

    Image

    There is no way to access the DM chat from the Reports > Reports tab, but we can still access it from Reports > Chats.

    Image

    If we don't want it to open on search money request report, then we can also apply the same fix to movedReportUrl.

  11. Krishna2323 commented on Oct 21, 2025

    @Krishna2323
    Contributor

    I will review the proposals today if possible, or tomorrow for sure.

  12. 14 remaining items

  13. removed
    Help Wanted
    on Oct 30, 2025
  14. melvin-bot commented on Oct 30, 2025

    @melvin-bot

    📣 @abzokhattab 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

    Offer link
    Upwork job
    Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
    Keep in mind: Code of Conduct | Contributing 📖

  15. added
    Reviewing
    Weekly
    and removed
    Daily
    on Oct 30, 2025
  16. abzokhattab commented on Oct 30, 2025

    @abzokhattab
    Contributor

    PR is ready #73884

    cc @Krishna2323

  17. puneetlath commented on Nov 13, 2025

    @puneetlath
    Contributor

    @NicMendonca FYI we are no longer going forward with this PR but should go ahead and pay the issue out. Context: #73884 (comment)

  18. Krishna2323 commented on Nov 24, 2025

    @Krishna2323
    Contributor

    @NicMendonca could you please post the payment summary when you get a chance? Thanks!

  19. added
    Daily
    and removed
    Weekly
    on Nov 27, 2025
  20. NicMendonca commented on Nov 27, 2025

    @NicMendonca
    Contributor

    Payment Summary

    Contributor: @abzokhattab due $250 via NewDot
    Contributor+: @Krishna2323 due $250 via NewDot

  21. garrettmknight commented on Dec 1, 2025

    @garrettmknight
    Contributor

    $250 approved for @abzokhattab

  22. Krishna2323 commented on Dec 6, 2025

    @Krishna2323
    Contributor

    Requested in ND.

  23. quinthar commented on Dec 8, 2025

    @quinthar
    Contributor

    Approved $250 to @Krishna2323

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

Metadata

Metadata

Labels

BugDailyExternalReviewing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions