Skip to content

[Due for payment 2025-08-01] [$250] Expense- "changed the workspace to" message becomes incomplete after leaving workspaces #64167

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.1.66-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp
Email or phone of affected tester (no customers): sdhdsnjoidjsojo2@gmail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.5 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • User is invited to three workspaces - A, B and C.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat A.
  3. Submit an expense to the workspace chat.
  4. Go to expense report.
  5. Click More > Change workspace.
  6. Select workspace B.
  7. Click More > Change workspace.
  8. Select workspace C.
  9. Leave workspace A and B.
  10. Go back to the expense report.

Expected Result:

"changed the workspace to" system message should read "changed the workspace".

Actual Result:

"changed the workspace to" system message becomes incomplete when user is no longer part of the involved workspaces.

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

Bug6859031_1749817536690.20250613_202139.mp4
Image

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021940357322143806192
  • Upwork Job ID: 1940357322143806192
  • Last Price Increase: 2025-07-02
  • Automatic offers:
    • FitseTLT | Contributor | 107913030
Issue OwnerCurrent Issue Owner: @dylanexpensify

Activity

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

    @melvin-bot

    Triggered auto assignment to @dylanexpensify (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. FitseTLT commented on Jun 13, 2025

    @FitseTLT
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-06-13 13:00:55 UTC.

    Proposal

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

    Expense- "changed the workspace to" message becomes incomplete after leaving workspaces

    What is the root cause of that problem?

    Whenever we couldn't get the name of the policy name here

    App/src/libs/ReportUtils.ts

    Lines 5870 to 5873 in 2908e67

    const message = translateLocal('report.actions.type.changeReportPolicy', {
    fromPolicyName: fromPolicyID ? getPolicyNameByID(fromPolicyID) : undefined,
    toPolicyName: getPolicyNameByID(toPolicyID),
    });

    couldn't be calculated due to workspace data not being available we display empty string after to on the copy here

    App/src/languages/en.ts

    Lines 5753 to 5754 in 2908e67

    changeReportPolicy: ({fromPolicyName, toPolicyName}: ChangeReportPolicyParams) =>
    `changed the workspace to ${toPolicyName}${fromPolicyName ? ` (previously ${fromPolicyName})` : ''}`,

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

    The lack of info is expected in the case of the wokspace deletion from onyx due to leaving workspace or deletion but our copy should treat that properly like we did for changedTransaction here

    movedTransaction: ({reportUrl, reportName}: MovedTransactionParams) => `moved this expense${reportName ? ` to <a href="${reportUrl}">${reportName}</a>` : ''}`,

    the to should only be displayed if the policy name exists other wise we should display a generic message of sth like changed the workspace like this

                        `changed the workspace${toPolicyName ? ` to ${toPolicyName}${fromPolicyName ? ` (previously ${fromPolicyName})` : ''}` : ''}`,
    
    

    But any general message can be suggested by the copy team. Because there might be several variations of the copy like if the toPolicy name doesnt exist but the fromPolicy name exists we can consider another copy which mentions the previous policy name but jumps the toPolicy name with a general text.
    Alternatively as the workspace id is always available we can display workspace #ID message but we need to discuss it with design team.

    If we can update the BE of course we can incorporate the policy names in the original messages of the actions and we can use them as a back up when we can't calculate it in the FE.

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

    If needed might add a test for getPolicyChangeMessage to cover this case of the policy not existing in onyx and the result depends on the method we are going to use to deal with the problem.

    What alternative solutions did you explore? (Optional)

    Though a bit costly, we can find (search) in allReports for an archived report linked to the policy and use the report's oldPolicyName prop to get the name but no report can still be found linked to the policy and the above update of the copy is mandatory I think.

    
    function getPolicyNameByID(policyID: string): string {
        return allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]?.name ?? Object.values(allReports ?? {}).find((report) => report?.policyID === policyID)?.oldPolicyName ?? '';
    }
    
  4. etCoderDysto commented on Jun 13, 2025

    @etCoderDysto
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-06-13 13:13:11 UTC.

    Proposal

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

    "changed the workspace to" message becomes incomplete after leaving workspaces

    What is the root cause of that problem?

    We call getPolicyChangeMessage, to get policy name for the system message. And getPolicyChangeMessage tries to fetch the policy name by first fetching policy using policyID. Since there is no policy in onyx that is associated with the deleted policyID there won't be no policy name.

    App/src/libs/ReportUtils.ts

    Lines 5867 to 5874 in 2908e67

    function getPolicyChangeMessage(action: ReportAction) {
    const PolicyChangeOriginalMessage = getOriginalMessage(action as ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY>) ?? {};
    const {fromPolicy: fromPolicyID, toPolicy: toPolicyID} = PolicyChangeOriginalMessage as OriginalMessageChangePolicy;
    const message = translateLocal('report.actions.type.changeReportPolicy', {
    fromPolicyName: fromPolicyID ? getPolicyNameByID(fromPolicyID) : undefined,
    toPolicyName: getPolicyNameByID(toPolicyID),
    });
    return message;

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

    When there is no policy that is associated with the policyID, we can use policy name from the archived report (report.policyName)

    1. We should get a report that is associated with the policy using getAllPolicyReports. Get the first report from the array of reports. Optionally we can create a utility function that returns the first report that is associated with the deleted poliyID
    2. Then we can use report.policyName prop to get the policy name

    We can do something like this below

    App/src/libs/PolicyUtils.ts

    Lines 236 to 238 in 2908e67

    function getPolicyNameByID(policyID: string): string {
    return allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]?.name ?? '';
    }

    function getPolicyNameByID(policyID: string): string {
        return allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]?.name ?? getAllPolicyReports(policyID)?.[0]?.policyName ?? '';
    }
    

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

    We can add test for getPolicyChangeMessage to assert that returns a policy name when passing a policyId of a deleted policy.

    What alternative solutions did you explore? (Optional)

    we can add a function that gets the first report that is associated with the policyID, and use it instead of getAllPolicyReports

    Optionally we can create a utility function that returns the first report that is associated with the deleted poliyID

    function getFirstReportByPolicyID(policyID: string): OnyxEntry<Report> | undefined {
        return Object.values(allReports ?? {}).find((report) => report?.policyID === policyID);
    }
    
  5. FitseTLT commented on Jun 13, 2025

    @FitseTLT
    Contributor

    Added alt solution

  6. etCoderDysto commented on Jun 13, 2025

    @etCoderDysto
    Contributor

    Proposal updated:

    Optionally we can create a utility function that returns the first report that is associated with the deleted poliyID

    On alternative solution, I have added implementation detail about my suggestion to create a utility function that returns the first report associated with with deleted policyID.

    Note for C+: I have already mentioned in my proposal that we can create utility function that can get the first report that is associated with the deleted policyID before the first proposal added alternative solution by adding implementation. The first proposal's alternative solution seems to come as mutation of my proposal.

  7. melvin-bot commented on Jun 17, 2025

    @melvin-bot

    @dylanexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  8. melvin-bot commented on Jun 19, 2025

    @melvin-bot

    @dylanexpensify Huh... This is 4 days overdue. Who can take care of this?

  9. melvin-bot commented on Jun 23, 2025

    @melvin-bot

    @dylanexpensify 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

  10. dylanexpensify commented on Jun 25, 2025

    @dylanexpensify
    Contributor

    Reviewing today!

  11. melvin-bot commented on Jun 27, 2025

    @melvin-bot

    @dylanexpensify this issue was created 2 weeks ago. Are we close to a solution? Let's make sure we're treating this as a top priority. Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

  12. 43 remaining items

  13. changed the title [-][$250] Expense- "changed the workspace to" message becomes incomplete after leaving workspaces[/-] [+][Due for payment 2025-08-01] [$250] Expense- "changed the workspace to" message becomes incomplete after leaving workspaces[/+] on Jul 25, 2025
  14. melvin-bot commented on Jul 25, 2025

    @melvin-bot

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

  15. melvin-bot commented on Jul 25, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.85-5 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-08-01. 🎊

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

  16. melvin-bot commented on Jul 25, 2025

    @melvin-bot

    @DylanDylann @dylanexpensify 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]

  17. DylanDylann commented on Aug 4, 2025

    @DylanDylann
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [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: None, this is not a bug. It is a case wasn't considered

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

    • [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 is invited to three workspaces - A, B and C.

    Test:

    1. Go to workspace chat A.
    2. Submit an expense to the workspace chat.
    3. Go to expense report.
    4. Click More > Change workspace.
    5. Select workspace B.
    6. Click More > Change workspace.
    7. Select workspace C.
    8. Leave workspace A and B.
    9. Go back to the expense report.
    10. Check that changed workspace system message linked to the workspaces you left from read "changed the workspace".

    Do we agree 👍 or 👎

  18. dylanexpensify commented on Aug 4, 2025

    @dylanexpensify
    Contributor

    Payment summary:

    Contributor: @FitseTLT $250 via Upwork
    Contributor+: @DylanDylann $250 via NewDot

    Please apply/request!

  19. quinthar commented on Oct 17, 2025

    @quinthar
    Contributor

    Approved $250 to @DylanDylann

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