Skip to content

Fix workspace chat opening with wrong UI when accessed from Reports - #73884

Closed
abzokhattab wants to merge 5 commits into
Expensify:mainfrom
abzokhattab:fix/workspace-chat-reports-link
Closed

abzokhattab wants to merge 5 commits into
Expensify:mainfrom
abzokhattab:fix/workspace-chat-reports-link

Conversation

@abzokhattab

@abzokhattab abzokhattab commented Oct 30, 2025 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Fixed Issues

$ #72792
PROPOSAL: #72792 (comment)

Tests

Precondition:
Account has a workspace

  1. User is logged in
  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"
  10. Verify that the workspace chat opens in the Inbox view (not in the Reports split view)

Offline tests

Same as tests

QA Steps

Same as tests

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Screen.Recording.2025-10-30.at.20.36.44.mov
Android: mWeb Chrome
Screen.Recording.2025-10-30.at.19.22.27.mov
iOS: Native
Screen.Recording.2025-10-30.at.19.26.01.mov
iOS: mWeb Safari
Screen.Recording.2025-10-30.at.19.23.57.mov
MacOS: Chrome / Safari
Screen.Recording.2025-10-30.at.16.26.51.mov
MacOS: Desktop
Screen.Recording.2025-10-30.at.19.27.06.mov

@abzokhattab
abzokhattab requested a review from a team as a code owner October 30, 2025 19:39
@melvin-bot
melvin-bot Bot requested review from Krishna2323 and removed request for a team October 30, 2025 19:39
@melvin-bot

melvin-bot Bot commented Oct 30, 2025

Copy link
Copy Markdown

@Krishna2323 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@codecov

codecov Bot commented Oct 30, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/libs/ReportUtils.ts 75.11% <80.00%> (+0.45%) ⬆️
... and 388 files with indirect coverage changes

Comment thread src/libs/ReportUtils.ts Outdated
if (!reportID) {
return `${environmentURL}/r/`;
}
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abzokhattab we should avoid using allReports as mentioned here. You should try passing the report object to the function.

@abzokhattab abzokhattab Oct 31, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding the report in the fucntion argument looks to be very complex requires many changes in those files + parent components... i am just afraid that these changes could break any of the existing functionalities 

Screenshot 2025-10-31 at 23 34 26

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abzokhattab I don’t think we should use allReports, as it will add more work for the team. We should consider making the change here itself. I also don’t think it would be very complex, because from what I can see, everywhere we use getReportURLForCurrentContext already has access to the report object. So we can simply pass it directly.

The only exception is in buildOptimisticMovedReportAction, where we need to get the report and then pass it to getReportURLForCurrentContext. And in places where buildOptimisticMovedReportAction is used, we already have the report as well — we just need to pass it two levels down.

Monosnap.screencast.2025-11-01.22-21-14.mp4

@abzokhattab abzokhattab Nov 1, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem is in the getMovedActionMessage... using the report in the two urls is wrong, they are two different reports ... this function is used by other functions that are used extensively,s uch as get report name, so what is the way to handle that

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed this. Using allReports could significantly increase the team’s workload.

@neil-marcellini, could you please share your thoughts?
@abzokhattab, have you looked for any other solutions? Or do you think this is doable but requires significant effort?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no i have tried but it doesnt work .. the changes are complex. especially for the getMovedActionMessage and all the functions above it .. were u able to make it work using this way?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abzokhattab I think we can do this instead:

  1. Update the getReportURLForCurrentContext function to accept an options parameter instead of a report:

    type GetReportURLForCurrentContextOptions = {
        report?: OnyxEntry<Report> | Report;
        /**
         * Explicitly indicate that the target is a workspace chat (policy expense chat).
         * Useful when the caller knows the destination report type but does not have the report object available.
         */
        isPolicyExpenseChat?: boolean;
    };
  2. Since newParentReportUrl will always be a policy expense chat, we can pass {isPolicyExpenseChat: true} from there.

  3. Pass the report object whenever it is available.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've implemented it, but it adds more complexity, and tbh I don't prefer to always hardcode the isPolicyExpenseChat: true , but I agree we don't have other options here

Please review and let me know if you have any comments

cc @neil-marcellini

@abzokhattab
abzokhattab force-pushed the fix/workspace-chat-reports-link branch from b240dbc to c22a13e Compare October 31, 2025 22:39
@abzokhattab
abzokhattab requested a review from a team as a code owner November 7, 2025 07:47
@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and removed request for a team November 7, 2025 07:47
@abzokhattab
abzokhattab force-pushed the fix/workspace-chat-reports-link branch from f85fa29 to c22a13e Compare November 7, 2025 07:51
@JmillsExpensify

Copy link
Copy Markdown
Contributor

This PR is interesting, in that I think we need to decide if we should be taking you between the Inbox and Reports page based on the link that you click. @Expensify/product-pr I'm curious for other's thoughts on this PR, though the basic case is this:

  • You're on the Reports page
  • You open a one-expense report (or open a batched expense report and click on an individual expense), then click on the expense thread message, "moved this report to the WORKSPACE LINK workspace"
  • What should happen next?

My feeling is that if you're on the Reports page, then you should stay on the Reports page. If you are alternatively on the Inbox then you stay on the Inbox. This PR makes it such that the user will always be taken to the Inbox though.

@heyjennahay

Copy link
Copy Markdown
Contributor

I agree with your @JmillsExpensify . I think you should stay in whatever area of the product you already are in

@Krishna2323

Copy link
Copy Markdown
Contributor

This PR makes it such that the user will always be taken to the Inbox though.

@JmillsExpensify Workspace expense chats are not designed to work in the Reports/Search context, which causes UI abnormalities.

image

@JmillsExpensify

Copy link
Copy Markdown
Contributor

Yes, thanks. I understand that, though why does this link take you to a workspace chat? I wouldn't expect it to, and I don't think our users would expect the same either.

@Krishna2323

Copy link
Copy Markdown
Contributor

though why does this link take you to a workspace chat? I wouldn't expect it to, and I don't think our users would expect the same either.

I think that’s expected, because when a report is moved from a user chat to a workspace, the system message says “Moved this report to the [WorkspaceName’s](link) workspace.” Shouldn’t the [WorkspaceName’s](link) point to the workspace expense chat?

image

@JmillsExpensify

Copy link
Copy Markdown
Contributor

I'm not sure if should. In fact, I guess I'm questioning why we hyperlink the workspace name? Like what is the value to the user. They just want to submit the report on the right workspace. That doesn't mean they need to go into the workspace chat.

@Krishna2323

Copy link
Copy Markdown
Contributor

@neil-marcellini could you please check the discussion above?

@abzokhattab

abzokhattab commented Nov 12, 2025 •

Copy link
Copy Markdown
Contributor Author

In my opinion if we want to keep the workspace hyperlinked, the hyperlink should redirect to the workspace settings not the expense

In general its a good practice to keep the hyperlink for the ease of navigation for users

@JmillsExpensify

Copy link
Copy Markdown
Contributor

In my opinion if we want to keep the workspace hyperlinked, the hyperlink should redirect to the workspace settings not the expense

That makes sense for admins, though I think it's a confusing paradigm for employees and individuals.

@trjExpensify

Copy link
Copy Markdown
Contributor

My feeling is that if you're on the Reports page, then you should stay on the Reports page. If you are alternatively on the Inbox then you stay on the Inbox.

I agree, but I thought that was done here after a PR @puneetlath created? #70509

@puneetlath

Copy link
Copy Markdown
Contributor

Actually, it looks like this hyperlink on the Reports page is going away altogether with the update to add columns for Reports. So I think actually these changes are no longer relevant.

So I'm going to go ahead and close this PR and we can pay out @Krishna2323 and @abzokhattab for their time. Thanks everyone and sorry for the confusion!

@puneetlath puneetlath closed this Nov 13, 2025
@JmillsExpensify

Copy link
Copy Markdown
Contributor

Sounds good to me. I'll comment on the issue so that BZ is in the loop.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants