Skip to content

[$500] Thread - App crashes when leaving thread #33009

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: 1.4.12-0
Reproducible in staging?: Y
Reproducible in production?: N
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: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to any chat
  3. Send a message
  4. Right click on the message > Reply in thread
  5. Send a reply in thread
  6. Click on the 3-dot menu > Leave thread

Expected Result:

App does not crash

Actual Result:

App crashes

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6312071_1702491924994.crash.mp4

logs.txt

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~013140a2456ce85a0b
  • Upwork Job ID: 1736678963183497216
  • Last Price Increase: 2024-01-08
  • Automatic offers:
    • situchan | Contributor | 28096745
Issue OwnerCurrent Issue Owner: @dylanexpensify

Activity

  1. github-actions commented on Dec 13, 2023

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  2. melvin-bot commented on Dec 13, 2023

    @melvin-bot

    Triggered auto assignment to @puneetlath (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

  3. abzokhattab commented on Dec 13, 2023

    @abzokhattab
    Contributor

    Proposal

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

    App crashes when leaving thread

    What is the root cause of that problem?

    in the following line report.notificationPreference is null so it throws an error when it tries to access the length.

    } else if ((isChatThread && props.report.notificationPreference.length) || isUserCreatedPolicyRoom || canLeaveRoom) {

    image

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

    this issue orginates because of the optimistic value we set when leaving a room:

    App/src/libs/actions/Report.ts

    Lines 2049 to 2058 in 41471e9

    value: {
    reportID,
    stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
    statusNum: CONST.REPORT.STATUS.CLOSED,
    chatType: report.chatType,
    parentReportID: report.parentReportID,
    parentReportActionID: report.parentReportActionID,
    policyID: report.policyID,
    type: report.type,
    },

    here we dont add the notificationPreference

    so we have two solutions

    either to add notificationPreference as hidden:

         : {
                      onyxMethod: Onyx.METHOD.SET,
                      key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
                      value: {
                          reportID,
                          stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
                          statusNum: CONST.REPORT.STATUS.CLOSED,
                          chatType: report.chatType,
                          parentReportID: report.parentReportID,
                          parentReportActionID: report.parentReportActionID,
                          policyID: report.policyID,
                          type: report.type,
                          notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
                      },

    or we add another condition that checks if thereport.notificationPreference exists first before accessing the length

    #POC

    Screen.Recording.2023-12-14.at.1.15.36.AM.mov
  4. situchan commented on Dec 13, 2023

    @situchan
    Contributor

    I confirmed that this also happens on production. Not deploy blocker but it would be good to fix asap as it's "crash"
    @abzokhattab's proposal looks good to me.

    In addition, we can add fix some more optimistic data to be consistent with server.
    For now, there's glitch. i.e. chat is archived optimistically and then restores back

    Screen.Recording.2023-12-14.at.3.39.42.AM.mov
  5. DylanDylann commented on Dec 14, 2023

    @DylanDylann
    Contributor

    @situchan sorry for my late, could you help to check my proposal?

    Proposal

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

    App crashes when leaving thread

    What is the root cause of that problem?

    When leaving the room we don't set notificationPreference in optimistic Data and we using SET method to update thread report to ONYX. It caused notificationPreference is lost in the chat report.
    One more thing, after leaving the room, the App don't redirect to the parent report.

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

    we need to add fully optimistic data to match the data from BE.

    I think we should redirect to the parent report after the user leaving room. In here


    we should update like this

     if (isWorkspaceMemberLeavingWorkspaceRoom) {
            const participantAccountIDs = PersonalDetailsUtils.getAccountIDsByLogins([CONST.EMAIL.CONCIERGE]);
            const chat = ReportUtils.getChatByParticipants(participantAccountIDs);
            if (chat?.reportID) {
                Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(chat.reportID));
            }
    + return
        }
    +    if (report?.parentReportID) {
    +      Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.parentReportID));
    +  }
    

    What alternative solutions did you explore? (Optional)

    NA

  6. Julesssss commented on Dec 14, 2023

    @Julesssss
    Contributor

    I confirmed that this also happens on production.

    I was unable to reproduce this on v1.4.11-25.

  7. situchan commented on Dec 14, 2023

    @situchan
    Contributor

    @Julesssss constantly reproducible on production
    Because of this crash, not able to test #33010. I think 2 issues can be fixed together in one PR.

    Screen.Recording.2023-12-14.at.4.29.46.PM.mov
  8. situchan commented on Dec 14, 2023

    @situchan
    Contributor

    Please test on public room

  9. Julesssss commented on Dec 14, 2023

    @Julesssss
    Contributor

    I can't reproduce this in a 1:1 chat on web or Android. But yeah I can reproduce in a public room.

    The problem is that a new regression has been introduced for the 1:1 chats, so as much as I'd like to drop this from being a blocker, we'll have to fix it asap.

  10. 61 remaining items

  11. Julesssss commented on Jan 12, 2024

    @Julesssss
    Contributor

    Hey @situchan did that work?

  12. situchan commented on Jan 12, 2024

    @situchan
    Contributor

    Hey @situchan did that work?

    Issue made internal after my comment so didn't work.
    Can you please remove Internal, unassign and assign me back?
    Thanks

  13. removed
    InternalRequires API changes or must be handled by Expensify staff
    on Jan 12, 2024
  14. removed
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jan 12, 2024
  15. melvin-bot commented on Jan 12, 2024

    @melvin-bot

    📣 @situchan 🎉 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 📖

  16. situchan commented on Jan 12, 2024

    @situchan
    Contributor

    Accepted offer. Thanks

  17. Julesssss commented on Jan 15, 2024

    @Julesssss
    Contributor

    Not overdue

  18. dylanexpensify commented on Jan 15, 2024

    @dylanexpensify
    Contributor

    paying now

  19. dylanexpensify commented on Jan 15, 2024

    @dylanexpensify
    Contributor

    done

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions