App icon indicating copy to clipboard operation
App copied to clipboard

[$1000] While deleting a workspace, the archive workspace rooms only become unread if user reloads the page.

Open kavimuru opened this issue 1 year ago • 18 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. Create a new Workspace, turn on #focus mode for easy check the unread status.
  2. Delete the workspace and wait.
  3. Notice that there's no new unread messages. Refresh the page.
  4. Notice that there are 2 unread messages from archive workspace.

Expected Result

User can see the unread messages without reloading the page.

Actual Result

User need to reload the page to see unread message.

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

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

  • [ ] Android / native
  • [ ] Android / Chrome
  • [ ] iOS / native
  • [ ] iOS / Safari
  • [x] MacOS / Chrome / Safari
  • [ ] MacOS / Desktop

Version Number: 1.3.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 Notes/Photos/Videos: Any additional supporting documentation

https://user-images.githubusercontent.com/43996225/232828062-5a4d79ea-4ae5-4808-bd16-0ce5ac00c444.mov

https://user-images.githubusercontent.com/43996225/232828114-3be6f4ca-fe84-48de-8a15-f5316f6c750f.mp4

Expensify/Expensify Issue URL: Issue reported by: @hungvu193 Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1681721180409989

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01b9fd19b5fce74e2b
  • Upwork Job ID: 1648888366298202112
  • Last Price Increase: 2023-04-27

kavimuru avatar Apr 18 '23 15:04 kavimuru

Triggered auto assignment to @strepanier03 (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

MelvinBot avatar Apr 18 '23 15:04 MelvinBot

Bug0 Triage Checklist (Main S/O)

  • [x] This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • [x] This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • [x] This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • [x] This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • [x] I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

MelvinBot avatar Apr 18 '23 15:04 MelvinBot

Job added to Upwork: https://www.upwork.com/jobs/~01b9fd19b5fce74e2b

MelvinBot avatar Apr 20 '23 03:04 MelvinBot

Current assignee @strepanier03 is eligible for the External assigner, not assigning anyone new.

MelvinBot avatar Apr 20 '23 03:04 MelvinBot

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

MelvinBot avatar Apr 20 '23 03:04 MelvinBot

Triggered auto assignment to @Julesssss (External), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

MelvinBot avatar Apr 20 '23 03:04 MelvinBot

Proposal

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

Deleted workspace chats becomes unread only after reloading the page.

What is the root cause of that problem?

The logic of unread is by comparing the lastVisibleActionCreated with lastReadTime. When we delete a workspace, we will create a new closed action. https://github.com/Expensify/App/blob/5cd0ab32ad0b3422dfcfe4d5d3996ae0b0d731fa/src/libs/actions/Policy.js#L98-L113 This is similar to how we create a new action when sending a message/chat. When a new action is created, we expect the lastVisibleActionCreated is also optimistically updated, which we already did when we send a chat,

https://github.com/Expensify/App/blob/5cd0ab32ad0b3422dfcfe4d5d3996ae0b0d731fa/src/libs/actions/Report.js#L207-L212 https://github.com/Expensify/App/blob/5cd0ab32ad0b3422dfcfe4d5d3996ae0b0d731fa/src/libs/actions/Report.js#L231-L236

but not when we create a close action.

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

To solve it, we should update the lastVisibleActionCreated here https://github.com/Expensify/App/blob/5cd0ab32ad0b3422dfcfe4d5d3996ae0b0d731fa/src/libs/actions/Policy.js#L87-L96

const currentTime = DateUtils.getDBTime();
...
lastVisibleActionCreated: currentTime,

bernhardoj avatar Apr 20 '23 03:04 bernhardoj

Proposal

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

Deleted workspace, the archive rooms doesn't become unread until user reloads the page. The problem also happens with delete member and add new member

What is the root cause of that problem?

we're using lastVisibleActionCreated to compare with lastReadTime to decide this report is unread or not

https://github.com/Expensify/App/blob/5cd0ab32ad0b3422dfcfe4d5d3996ae0b0d731fa/src/libs/ReportUtils.js#L1345-L1354

But when delete the workspace, add member or delete member we haven't added lastVisibleActionCreated to optimistic data as we did with adding new message.

https://github.com/Expensify/App/blob/5cd0ab32ad0b3422dfcfe4d5d3996ae0b0d731fa/src/libs/actions/Policy.js#L77-L96

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

Delete workspace: We have only 2 rooms need to become unread: announce room and admin room, so just need to update if it's admin or announce:

    const currentTime = DateUtils.getDBTime();
...

...((chatType === CONST.REPORT.CHAT_TYPE.POLICY_ADMINS || chatType == CONST.REPORT.CHAT_TYPE.POLICY_ANNOUNCE)? {
                    lastVisibleActionCreated:currentTime
                }:{}

Add member and delete member When add new member or delete member, just only admin room should become unread

=> We have to find the admin room to update lastVisibleActionCreated

Here is my sample code:

    const currentTime = DateUtils.getDBTime();
    const reports=ReportUtils.getAllPolicyReports(policyID);
    const adminReport = ReportUtils.findAdminRoom(reports);
    const optimisticData = [
        {
            onyxMethod: CONST.ONYX.METHOD.MERGE,
            key: membersListKey,

            // Convert to object with each key containing {pendingAction: ‘add’}
            value: _.object(logins, Array(logins.length).fill({pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD})),

        },
        {
            onyxMethod: CONST.ONYX.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT}${adminReport.reportID}`,
            value:{
                lastVisibleActionCreated: currentTime,
            }
        }
    ];

https://github.com/Expensify/App/blob/5cd0ab32ad0b3422dfcfe4d5d3996ae0b0d731fa/src/libs/actions/Policy.js#L241-L249

tienifr avatar Apr 20 '23 04:04 tienifr

Not overdue, just open for proposals yesterday.

0xmiroslav avatar Apr 21 '23 14:04 0xmiroslav

Just a note:

  1. We create closed action to all workspace chats which means we also should update the lastVisibleActionCreated for all of those chats
  2. I think updating lastVisibleActionCreated for delete/add member is out of scope. Currently, we don't optimistically create an action for delete/add (we already have this issue here https://github.com/Expensify/App/issues/17771). If we update lastVisibleActionCreated, it will make the chat becomes unread, but when the user opens the chat, nothing is new which confuse the user. We don't even know what kind of data the added/removed action should have. I don't even remember we have this added/removed action, is it a new feature? Maybe the implementation is only done on the BE?

bernhardoj avatar Apr 21 '23 15:04 bernhardoj

All good Melvin, waiting for some proposals or recommendations of next steps.

strepanier03 avatar Apr 24 '23 18:04 strepanier03

After testing, I see only 2 rooms are updated to be unread from BE side: announce room and admin room. If we want to update all of those chats we have to fix it on BE side as well. But I think it's not necessary

tienifr avatar Apr 25 '23 11:04 tienifr

Sharing my finding too. I'm assuming the other room besides announce and admin is the policy room which is behind beta feature. When I delete a workspace that has a policy room, yes, the policy room stays as a read chat.

(policy room example) image

(optimistically deleted policy room) image image

However, I found that when we open the policy room, we will get an error

image

I'm assuming that the room is completely deleted (not archived) in the BE. So, I validate my assumption by logging in with the same account on different client/device and found out that the room completely deleted from my chat, thus I got the error. This means that we shouldn't create the closed action for policy room and delete it instead, but I (or maybe even we) don't even know what is the expected behavior because the feature is still behind the beta.

bernhardoj avatar Apr 25 '23 13:04 bernhardoj

@bernhardoj @tienifr - Would you suggest this be an internal issue since it needs to be fixed on the backend then?

strepanier03 avatar Apr 25 '23 16:04 strepanier03

I am going to be OoO from April 26-May 3. I plan to leave this GH assigned to me during my out-of-office as it likely won't need my action before I return. If it needs to be switched to Internal, @Julesssss can do that.

If something changes and action is needed from the BugZero team, please reach out in #expensify-open-source to request help from another team member.

Thanks, chat with you when I get back!

strepanier03 avatar Apr 25 '23 21:04 strepanier03

I'm not sure whether this should be internal or not.

To summarize the discussion, we are discussing whether we should mark all deleted workspace's chats as unread or just #admins and #announce. Based on the front end code, we optimistically archive and create close action for all workspace's chats, which is make sense to mark those chats unread. However, on BE, POSSIBLY we archive and create close action only for #admins and #announce chats (other chats is completely deleted, which means you can't find the chats in LHN).

The options I see are:

  1. Mark all chats linked to the workspace as unread (this is assuming the FE logic is the correct one) or
  2. Follow the BE logic (assuming the BE logic is the correct one), which we need the help from the internal team.

There are 2 options because I think workspace linked chats (beside #admins and #announce) are still behind the beta feature, so we are still working on what is the expected behavior would be.

bernhardoj avatar Apr 26 '23 05:04 bernhardoj

Thanks for the overview. I need to take a detailed look and will report back soon

Julesssss avatar Apr 26 '23 10:04 Julesssss

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

MelvinBot avatar Apr 27 '23 16:04 MelvinBot

Taking another look today

Julesssss avatar May 02 '23 08:05 Julesssss

Okay, so I think we do need to push data form the backend to resolve this. It's going to take a while to prioritise though, so I'm holding for now.

Julesssss avatar May 02 '23 11:05 Julesssss

@Julesssss should I update the label to internal and is Daily still the correct label if we can't prioritize yet?

strepanier03 avatar May 04 '23 21:05 strepanier03

Hey @strepanier03, yeah I think so. I think it's unlikely I can prioritize anytime soon though.

Julesssss avatar May 05 '23 08:05 Julesssss

Current assignee @0xmiroslav is eligible for the Internal assigner, not assigning anyone new.

melvin-bot[bot] avatar May 05 '23 08:05 melvin-bot[bot]

Just touching base @Julesssss - Leaving this monthly appropriate?

strepanier03 avatar Jun 06 '23 02:06 strepanier03

Yeah, I'm not able to prioritise yet.

Julesssss avatar Jun 06 '23 08:06 Julesssss

Triggered auto assignment to @joekaufmanexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

melvin-bot[bot] avatar Jun 13 '23 20:06 melvin-bot[bot]

Bug0 Triage Checklist (Main S/O)

  • [ ] This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • [ ] This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • [ ] This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • [ ] This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • [ ] I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

melvin-bot[bot] avatar Jun 13 '23 20:06 melvin-bot[bot]

@joekaufmanexpensify - I am heading out on sabbatical and this won't be off hold until after I'm already gone.

I'm reassigning a BZ to it for when action is needed. Thanks so much for taking it over.

strepanier03 avatar Jun 13 '23 20:06 strepanier03

Happy to help! @Julesssss I'm catching up on this now, and just for my own understanding, is this held on any other issues?

joekaufmanexpensify avatar Jun 13 '23 20:06 joekaufmanexpensify

Followed up on this

joekaufmanexpensify avatar Jun 16 '23 12:06 joekaufmanexpensify