Skip to content

[Due for payment 2025-12-31] [$250] Self DM chat appears briefly when open chat with secondary login #75956

Closed

Description

@mitarachim

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: v9.2.63-0
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-2156/folder/13176682/41236552/1035951028
Email or phone of affected tester (no customers): gocemate+b2155687@gmail.com
Issue reported by: Applause Internal Team
Device used: Lenovo 80ES / Windows 10 Pro
App Component: Chat Report View

Action Performed:

Precondition:

  1. Prepare an account that has a secondary login assigned
  2. Log in with another account and start a conversation with the primary login of the account from step 1
  3. Send some messages in the conversation

Steps

  1. Log in with the account that has the conversation with the user that has 2 logins
  2. Click on FAB
  3. Click on New Chat
  4. Search for the Secondary login of the account
  5. Verify you're redirected to the conversation with the primary login email

Expected Result:

Self DM chat should not appear when navigate to secondary login chat

Actual Result:

Self DM chat appears briefly when navigate to secondary login chat

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

Bug7012580_1764026362699.Recording__40.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021993529348918579912
  • Upwork Job ID: 1993529348918579912
  • Last Price Increase: 2025-12-10
Issue OwnerCurrent Issue Owner: @strepanier03

Activity

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

    @melvin-bot

    Triggered auto assignment to @strepanier03 (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. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Nov 26, 2025
  4. changed the title [-]Self DM chat appears briefly when open chat with secondary login[/-] [+][$250] Self DM chat appears briefly when open chat with secondary login[/+] on Nov 26, 2025
  5. melvin-bot commented on Nov 26, 2025

    @melvin-bot
  6. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Nov 26, 2025
  7. melvin-bot commented on Nov 26, 2025

    @melvin-bot

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

  8. bernhardoj commented on Nov 26, 2025

    @bernhardoj
    Contributor

    to check if a login belongs to the current user's loginList before generating an optimistic ID. If the login is found in loginList, use currentUserAccountID instead.
    allowing getChatByParticipants() to find the existing chat instead of creating a new optimistic Self DM.

    @TaduJR The issue happens when you search other user's secondary login. It's expected that an optimistic report will be created and later be redirected to the primary user login's report. The problem here is the secondary login's report shows the current user information.

  9. bernhardoj commented on Nov 28, 2025

    @bernhardoj
    Contributor

    Posted in Slack to get more proposals...

  10. TaduJR commented on Nov 28, 2025

    @TaduJR
    Contributor

    Hey @bernhardoj

    Thank you for your review.

    Unfortunately, I am having blockers on another PR, need to focus on that one.

    Withdrawing Proposal.

  11. eh2077 commented on Dec 1, 2025

    @eh2077
    Contributor

    Proposal

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

    Self DM chat appears when a new chat redirect to an existing chat.

    What is the root cause of that problem?

    The root cause of this issue is that we clear optimistic participant when creating a new chat report

    App/src/libs/actions/Report.ts

    Lines 1268 to 1274 in fbed79d

    successData.push(
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
    value: {
    participants: redundantParticipants,
    pendingFields: {

    So, there's only one participant, the current user, left in report.participants. The current user participant should only be used when it's self DM chat but there's a bug in method isOneOnOneChat when participantAmount is 0

    App/src/libs/ReportUtils.ts

    Lines 2607 to 2614 in fbed79d

    function isOneOnOneChat(report: OnyxEntry<Report>): boolean {
    const participants = report?.participants ?? {};
    const participant = currentUserAccountID ? participants[currentUserAccountID] : undefined;
    const isCurrentUserParticipant = participant ? 1 : 0;
    const participantAmount = Object.keys(participants).length - isCurrentUserParticipant;
    if (participantAmount !== 1) {
    return false;
    }

    const shouldExcludeCurrentUser = isOneOnOneChat(report) || isSystemChat(report) || shouldForceExcludeCurrentUser;

    const allParticipants = getParticipantsAccountIDsForDisplay(report, false, true, undefined, reportMetadata);

    Same issue happens when the open a new chat request redirects an preexistingReportID which is unknown at client, see here

    App/src/libs/actions/Report.ts

    Lines 1875 to 1881 in fbed79d

    Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${preexistingReportID}`, {
    ...report,
    reportID: preexistingReportID,
    preexistingReportID: null,
    // Replacing the existing report's participants to avoid duplicates
    participants: existingReport?.participants ?? report.participants,
    });

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

    The most intuitive fix will be in method isOneOnOneChat

    App/src/libs/ReportUtils.ts

    Lines 2607 to 2614 in fbed79d

    function isOneOnOneChat(report: OnyxEntry<Report>): boolean {
    const participants = report?.participants ?? {};
    const participant = currentUserAccountID ? participants[currentUserAccountID] : undefined;
    const isCurrentUserParticipant = participant ? 1 : 0;
    const participantAmount = Object.keys(participants).length - isCurrentUserParticipant;
    if (participantAmount !== 1) {
    return false;
    }

        if (participantAmount > 1) {
            return false;
        }

    What alternative solutions did you explore? (Optional)

    We should figure out a better mechanism to update report data for this use case

    1. openReport with a new chat, which BE returns info to redirect to preexistingReportID
    2. openReport with preexistingReportID

    The current implementation clean up optimistic report participant data after the first request is returned, there's a timing issue before the second request succeeded.

    I think a potential better solution is to clean up optimistic report and participant data after the second request is returned. But it's more complex to coordinate and we don't have this pattern in the App. That said, I think we can use the main solution at the moment.

  12. 44 remaining items

  13. melvin-bot commented on Dec 24, 2025

    @melvin-bot

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

  14. melvin-bot commented on Dec 24, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.86-4 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-12-31. 🎊

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

    • @bernhardoj requires payment through NewDot Manual Requests
    • @eh2077 requires payment through NewDot Manual Requests
  15. melvin-bot commented on Dec 24, 2025

    @melvin-bot

    @bernhardoj / @eh2077 @strepanier03 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]

  16. bernhardoj commented on Dec 26, 2025

    @bernhardoj
    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: https://github.com/Expensify/App/pull/70240/files#r2647352243

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

    Regression Test Proposal Template

    Regression Test Proposal

    Precondition:

    • Have an account that has a secondary login assigned

    Test:

    1. Press on FAB > Start chat > Chat tab
    2. Search for the secondary login of the account from the precondition and open it
    3. Verify the secondary login report isn't turned into a self DM
    4. Verify you're redirected to the conversation with the primary login email

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-81ff-a333-9fc4-2fe9bb3bc234
  17. strepanier03 commented on Dec 30, 2025

    @strepanier03
    Contributor

    Payment summary

    For: #77885

    • $250 - @bernhardoj requires payment through NewDot Manual Requests
    • $250 - @eh2077 requires payment through NewDot Manual Requests
  18. bernhardoj commented on Dec 31, 2025

    @bernhardoj
    Contributor

    Requested in ND.

  19. garrettmknight commented on Jan 5, 2026

    @garrettmknight
    Contributor

    $250 approved for @bernhardoj

  20. JmillsExpensify commented on Jan 8, 2026

    @JmillsExpensify
    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

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