Skip to content

[Due for payment 2025-10-22] [Due for payment 2025-10-03] [$250] Clicking Report Link in Report History Navigates to Inbox Instead of Reports Page #70509

Closed

Description

@m-natarajan

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.13-1
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @puneetlath
Slack conversation (hyperlinked to channel name): #Expensify Migrate

Action Performed:

Precondition: User have an expense moved from one report to other

  1. Go to the Reports > Expense page
  2. Open an expense and scroll to its report history
  3. Click on the report link from the moved this expense thread
  4. Observe the navigation behavior

Expected Result:

The clicked link should open in the Reports page context

Actual Result:

The clicked link opens in the Inbox instead.

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

The link for the FS is in OP

Recording.1645.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021967521875052853454
  • Upwork Job ID: 1967521875052853454
  • Last Price Increase: 2025-09-15
  • Automatic offers:
    • ShridharGoel | Contributor | 108857523
Issue OwnerCurrent Issue Owner: @laurenreidexpensify

Activity

  1. added
    Daily
    Bug
    on Sep 12, 2025
  2. melvin-bot commented on Sep 12, 2025

    @melvin-bot

    Triggered auto assignment to @laurenreidexpensify (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. daledah commented on Sep 12, 2025

    @daledah
    Contributor

    Proposal

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

    The clicked link opens in the Inbox instead.

    What is the root cause of that problem?

    We always redirect to report here

    App/src/libs/ReportUtils.ts

    Lines 6304 to 6311 in 3938e13

    function getUnreportedTransactionMessage() {
    const selfDMReportID = findSelfDMReportID();
    const reportUrl = `${environmentURL}/r/${selfDMReportID}`;
    const message = translateLocal('iou.unreportedTransaction', {
    reportUrl,
    });
    return message;
    }

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

    We should check if isSearchTopmostFullScreenRoute is true, we should show it in the Reports Page

      function getUnreportedTransactionMessage() {
          const selfDMReportID = findSelfDMReportID();
          const reportUrl = isSearchTopmostFullScreenRoute() ? `${environmentURL}/search/view/${selfDMReportID}` : `${environmentURL}/r/${selfDMReportID}`;
          const message = translateLocal('iou.unreportedTransaction', {
              reportUrl,
          });
          return message;
      }
    

    In case we only want to navigate to Reports Page if the RHP is open, we can use

        const reportUrl = isSearchTopmostFullScreenRoute() && isReportOpenInRHP(navigationRef.getState()) ? `${environmentURL}/search/view/${selfDMReportID}` : `${environmentURL}/r/${selfDMReportID}`;
    

    Note: we can do the same with other moved messages like getMovedTransactionMessage, getMovedActionMessage, ...

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

    None

    What alternative solutions did you explore? (Optional)

    Result:

    Screen.Recording.2025-09-13.at.06.45.55.mov

    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.

  4. ShridharGoel commented on Sep 13, 2025

    @ShridharGoel
    Contributor

    Proposal

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

    When viewing an expense in Reports > Expenses, clicking the report link inside the "moved this expense" message opens the target in the Inbox context instead of staying within Reports. Users expect navigation to remain in the Reports context when the action originates from there.

    What is the root cause of that problem?

    The HTML for the moved-expense/moved-report messages hardcodes links to the Inbox route schema /r/:reportID. These links are generated in src/libs/ReportUtils.ts without considering whether the user is currently viewing Reports (Search) or Inbox.

    App/src/libs/ReportUtils.ts

    Lines 6294 to 6302 in 3938e13

    function getMovedTransactionMessage(report: OnyxEntry<Report>) {
    const reportName = getReportName(report) ?? report?.reportName ?? '';
    const reportUrl = `${environmentURL}/r/${report?.reportID}`;
    const message = translateLocal('iou.movedTransaction', {
    reportUrl,
    reportName,
    });
    return message;
    }

    App/src/libs/ReportUtils.ts

    Lines 6313 to 6330 in 3938e13

    function getMovedActionMessage(action: ReportAction, report: OnyxEntry<Report>) {
    if (!isMovedAction(action)) {
    return '';
    }
    const movedActionOriginalMessage = getOriginalMessage(action);
    if (!movedActionOriginalMessage) {
    return '';
    }
    const {toPolicyID, newParentReportID, movedReportID} = movedActionOriginalMessage;
    const toPolicyName = getPolicyNameByID(toPolicyID);
    return translateLocal('iou.movedAction', {
    shouldHideMovedReportUrl: !isDM(report),
    movedReportUrl: `${environmentURL}/r/${movedReportID}`,
    newParentReportUrl: `${environmentURL}/r/${newParentReportID}`,
    toPolicyName,
    });
    }

    App/src/libs/ReportUtils.ts

    Lines 6733 to 6770 in 3938e13

    function buildOptimisticTransactionAction(
    type: typeof CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION | typeof CONST.REPORT.ACTIONS.TYPE.UNREPORTED_TRANSACTION,
    transactionThreadReportID: string | undefined,
    targetReportID: string,
    ): ReportAction {
    const reportName = allReports?.[targetReportID]?.reportName ?? '';
    const url = `${environmentURL}/r/${targetReportID}`;
    const [actionText, messageHtml] =
    type === CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION
    ? [`moved this expense to ${reportName}`, `moved this expense to <a href='${url}' target='_blank' rel='noreferrer noopener'>${reportName}</a>`]
    : ['moved this expense to your personal space', 'moved this expense to your personal space'];
    return {
    actionName: type,
    reportID: transactionThreadReportID,
    actorAccountID: currentUserAccountID,
    avatar: getCurrentUserAvatar(),
    created: DateUtils.getDBTime(),
    originalMessage: type === CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION ? {toReportID: targetReportID} : {fromReportID: targetReportID},
    message: [
    {
    type: CONST.REPORT.MESSAGE.TYPE.TEXT,
    html: messageHtml,
    text: actionText,
    },
    ],
    person: [
    {
    style: 'strong',
    text: getCurrentUserDisplayNameOrEmail(),
    type: 'TEXT',
    },
    ],
    reportActionID: rand64(),
    shouldShow: true,
    pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
    };
    }

    App/src/libs/ReportUtils.ts

    Lines 6648 to 6656 in 3938e13

    const movedActionMessage = [
    {
    html: shouldHideMovedReportUrl
    ? `moved this <a href='${CONST.NEW_EXPENSIFY_URL}r/${movedReportID}' target='_blank' rel='noreferrer noopener'>report</a> to the <a href='${CONST.NEW_EXPENSIFY_URL}r/${newParentReportID}' target='_blank' rel='noreferrer noopener'>${policyName}</a> workspace`
    : `moved this report to the <a href='${CONST.NEW_EXPENSIFY_URL}r/${newParentReportID}' target='_blank' rel='noreferrer noopener'>${policyName}</a> workspace`,
    text: `moved this report to the ${policyName} workspace`,
    type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
    },
    ];

    Because these anchors point to /r/:id, clicking them navigates to the Inbox stack even when clicked from Reports.

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

    Introduce a small helper in ReportUtils that builds a report URL based on the current navigation context. We reuse the same context-detection used by other working links (e.g., the top-right "From Expense Report …" link), by checking whether the Search full-screen navigator is topmost via isSearchTopmostFullScreenRoute().

    Then, update all moved-expense/moved-report message builders to use this helper, so:

    • When the user is in Reports (Search), links point to search/r/:reportID (Reports context).
    • Otherwise, links point to r/:reportID (Inbox context).

    Updated snippets in src/libs/ReportUtils.ts:

    // Centralized URL builder used by message generators
    function getReportURLForCurrentContext(reportID: string | number | undefined): string {
        const id = String(reportID ?? '');
        if (!id) {
            return `${environmentURL}/r/`;
        }
        const isInSearchContext = isSearchTopmostFullScreenRoute();
        const relativePath = isInSearchContext
            ? ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID: id})
            : ROUTES.REPORT_WITH_ID.getRoute(id);
        return `${environmentURL}/${relativePath}`;
    }
    // 1) Moved transaction message
    function getMovedTransactionMessage(report: OnyxEntry<Report>) {
        const reportName = getReportName(report) ?? report?.reportName ?? '';
        const reportUrl = getReportURLForCurrentContext(report?.reportID);
        return translateLocal('iou.movedTransaction', {reportUrl, reportName});
    }
    // 2) Moved action (moved report) message
    function getMovedActionMessage(action: ReportAction, report: OnyxEntry<Report>) {
        // ...
        return translateLocal('iou.movedAction', {
            shouldHideMovedReportUrl: !isDM(report),
            movedReportUrl: getReportURLForCurrentContext(movedReportID),
            newParentReportUrl: getReportURLForCurrentContext(newParentReportID),
            toPolicyName,
        });
    }
    // 3) Optimistic moved transaction message HTML
    function buildOptimisticTransactionAction(/* ... */) {
        const reportName = allReports?.[targetReportID]?.reportName ?? '';
        const url = getReportURLForCurrentContext(targetReportID);
        const [actionText, messageHtml] = [
            `moved this expense to ${reportName}`,
            `moved this expense to <a href='${url}' target='_blank' rel='noreferrer noopener'>${reportName}</a>`,
        ];
        // ...
    }
    // 4) Optimistic moved report message HTML (used when moving reports across workspaces)
    const movedActionMessage = [
        {
            html: shouldHideMovedReportUrl
                ? `moved this <a href='${getReportURLForCurrentContext(movedReportID)}' target='_blank' rel='noreferrer noopener'>report</a> to the <a href='${getReportURLForCurrentContext(newParentReportID)}' target='_blank' rel='noreferrer noopener'>${policyName}</a> workspace`
                : `moved this report to the <a href='${getReportURLForCurrentContext(newParentReportID)}' target='_blank' rel='noreferrer noopener'>${policyName}</a> workspace`,
            text: `moved this report to the ${policyName} workspace`,
            type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
        },
    ];

    This mirrors the successful behavior of the existing parent-navigation subtitle link, so clicking the report link in the message now stays in Reports when the user is already there, and stays in Inbox when originating from Inbox.

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

    • When isSearchTopmostFullScreenRoute() returns true, getReportURLForCurrentContext('123') builds .../search/r/123.
    • When it returns false, the helper builds .../r/123. etc.
  5. added
    External
    on Sep 15, 2025
  6. changed the title [-]Clicking Report Link in Report History Navigates to Inbox Instead of Reports Page[/-] [+][$250] Clicking Report Link in Report History Navigates to Inbox Instead of Reports Page[/+] on Sep 15, 2025
  7. melvin-bot commented on Sep 15, 2025

    @melvin-bot
  8. added
    Help Wanted
    on Sep 15, 2025
  9. melvin-bot commented on Sep 15, 2025

    @melvin-bot

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

  10. 62 remaining items

  11. removed
    Reviewing
    on Oct 15, 2025
  12. melvin-bot commented on Oct 15, 2025

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  13. melvin-bot commented on Oct 15, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.31-2 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2025-10-22. 🎊

    For reference, here are some details about the assignees on this issue:

  14. melvin-bot commented on Oct 15, 2025

    @melvin-bot

    @ikevin127 The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  15. ShridharGoel commented on Oct 18, 2025

    @ShridharGoel
    Contributor

    @laurenreidexpensify I'll be requesting via ND, once this is due for payment. Thanks.

  16. ikevin127 commented on Oct 18, 2025

    @ikevin127
    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: N/A - Result of the original design

    • [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: N/A

    • [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: User has an expense moved from one report to another.

    1. Go to the Reports > Expense page.
    2. Open an expense and scroll to its report history.
    3. Click on the report link from the moved this expense thread.
    4. Verify that the report link opens within the Reports page.

    Do we agree 👍 or 👎.

  17. melvin-bot commented on Oct 22, 2025

    @melvin-bot

    Issue is ready for payment but no BZ is assigned. @dylanexpensify you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks!

  18. laurenreidexpensify commented on Oct 23, 2025

    @laurenreidexpensify
    Contributor

    Summary

    C+ $250 can request payment in Expensify @ikevin127
    Contributor $250 can request payment in Expensify @ShridharGoel

  19. moved this from MEDIUM or LOW to Done in [#whatsnext] #migrateon Oct 23, 2025
  20. garrettmknight commented on Oct 24, 2025

    @garrettmknight
    Contributor

    $250 approved for @ikevin127

  21. ShridharGoel commented on Oct 28, 2025

    @ShridharGoel
    Contributor

    @garrettmknight Can you check mine as well?

  22. garrettmknight commented on Oct 29, 2025

    @garrettmknight
    Contributor

    $250 approved for @ShridharGoel

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

Metadata

Metadata

Labels

Awaiting PaymentBugExternalWeekly

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions