Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[$500] Web - User can still access attachment thread after left the thread #27427

Closed
1 of 6 tasks
kbecciv opened this issue Sep 14, 2023 · 16 comments
Closed
1 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@kbecciv
Copy link

kbecciv commented Sep 14, 2023

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. Open the app on chrome, reply on someone by sending an attachment and click on "reply on thread" on the attachment
  2. Reply by sending messages
  3. Open the [Attachment] message and click on "Leave thread".
  4. "Hm... it's not here You don't have access to this chat" message will be shown but then you'll be redirected to the attachment you have left and supposed to have no access anymore (based on what the previous description showed).

Expected Result:

It should be showing a skeleton after user left the tread

Actual Result:

User can still access attachment thread after left the thread

Workaround:

Unknown

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.67-2
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

2023-09-11.22-20-43.mp4
Recording.4455.mp4

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0137f77b386e8c8eb4
  • Upwork Job ID: 1702274114805768192
  • Last Price Increase: 2023-09-21
@kbecciv kbecciv added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 14, 2023
@melvin-bot melvin-bot bot changed the title Web - User can still access attachment thread after left the thread [$500] Web - User can still access attachment thread after left the thread Sep 14, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 14, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 14, 2023

Job added to Upwork: https://www.upwork.com/jobs/~0137f77b386e8c8eb4

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 14, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 14, 2023

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
Copy link

melvin-bot bot commented Sep 14, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 14, 2023

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

@garrettmknight garrettmknight removed their assignment Sep 14, 2023
@sumairq
Copy link

sumairq commented Sep 14, 2023

Proposed solution

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

User can still access attachment thread after they leave the the thread.

What is the root cause of that problem?**

In ReportScreenWe don't get rid of reportID even after leaving the thread due to which <FullPageNotFoundView> component does not replace the child components with not found view as it depends on 'repordID' returning a falsy value.

reportId

We see the You don't have access to this chat only temporarily because the report object is temporarily empty and unpopulated and as soon as it is available the chat shows again because the reportID is still there.

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

    • Make sure that the Report.leaveRoom() action is properly disposing off the reportID in report from state when a person leaves a thread with attachment.

What alternative solutions did you explore? (Optional)

none

@huzaifa-99
Copy link
Contributor

huzaifa-99 commented Sep 14, 2023

Proposal

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

I believe that a user shouldn't be prevented from accessing a thread, even if they leave it. A thread is a part of a chat, and if user has access to a chat they should be able to access any thread in that chat.

Based on this assumption, I think the problem to solve is that the Hm... it's not here You don't have access to this chat message shouldn't be displayed (even momentarily) when visiting a thread that a user just left.

What is the root cause of that problem?

We clear the report object when a user leaves a thread and when the user visits the same thread report again, the empty report object causes the ReportScreen to show the 'Hmm.. its not there' message momentarily until the API call for OpenReport finishes.

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

In ReportScreen here, update the isLoading state to also handle empty report object cases by adding _.isEmpty(report), so it would become something like this

// pseudocode
const isLoading = !reportID || _.isEmpty(report) || !isSidebarLoaded || _.isEmpty(personalDetails) || firstRenderRef.current;

When the OpenReport call finishes this report object will be populated and will show the messages, during this load time the skeleton UI will be shown.

What alternative solutions did you explore? (Optional)

N/A

@bernhardoj
Copy link
Contributor

Proposal

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

The written issue is, that the user can access the same thread after leaving it, but in my opinion, that is expected. I agree with @huzaifa-99 that the real issue is, that rejoining the same thread shouldn't show the not found page but should show skeletons.

What is the root cause of that problem?

When we leave a thread, we clear the report data from onyx.

App/src/libs/actions/Report.js

Lines 1794 to 1812 in 63a5776

optimisticData: [
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: {
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
statusNum: CONST.REPORT.STATUS.CLOSED,
},
},
],
// Manually clear the report using merge. Should not use set here since it would cause race condition
// if it was called right after a merge.
successData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: _.object(reportKeys, Array(reportKeys.length).fill(null)),
},
],

In ReportScreen we show the not found page if reportID does not exist, isLoadingReportActions is false, and isLoading is false.

<FullPageNotFoundView
shouldShow={(!report.reportID && !report.isLoadingReportActions && !isLoading) || shouldHideReport}

When we rejoin the same thread, reportID is obviously empty but isLoadingReportActions should be true. The problem is, that we don't clear the report actions when leaving a room, so when we do an openReport request, we won't set the isLoadingReportActions property to true which is useful to "bypass" the not found page and show the skeletons.

value: reportActionsExist(reportID)
? {}
: {
isLoadingReportActions: true,
isLoadingMoreReportActions: false,
reportName: lodashGet(allReports, [reportID, 'reportName'], CONST.REPORT.DEFAULT_REPORT_NAME),
},

{(!isReportReadyForDisplay || isLoadingInitialReportActions || isLoading) && <ReportActionsSkeletonView containerHeight={skeletonViewContainerHeight} />}

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

Clear the report actions optimistically when leaving a thread and revert it when the request fails.

const reportActions = allReportActions[reportID];
optimisticData: [..., {
    onyxMethod: Onyx.METHOD.SET,
    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
    value: null,
}]
failureData: [..., {
    onyxMethod: Onyx.METHOD.SET,
    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
    value: reportActions,
}]

so when joining the thread again, we will reload the report actions too, and thus show the skeletons.

note: this solution currently doesn't work because we have an onyx issue where setting null doesn't clear the data.

@melvin-bot melvin-bot bot added the Overdue label Sep 18, 2023
@adelekennedy
Copy link

@eVoloshchak please review the above

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Sep 18, 2023
@adelekennedy
Copy link

@eVoloshchak review on the above please

@melvin-bot melvin-bot bot removed the Overdue label Sep 21, 2023
@eVoloshchak
Copy link
Contributor

Is this bug still present?
I can't reproduce using the steps from the description, it already works exactly as it should, showing the skeleton while loading

Screen.Recording.2023-09-21.at.14.46.22.mov

@bernhardoj
Copy link
Contributor

It is fixed in #26602

@melvin-bot
Copy link

melvin-bot bot commented Sep 21, 2023

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

@eVoloshchak
Copy link
Contributor

@adelekennedy, could you close this one, please? It was resolved by another PR

@adelekennedy
Copy link

I think just the reporting bonus is due in that case

@melvin-bot melvin-bot bot added the Overdue label Sep 25, 2023
@adelekennedy
Copy link

asked in Slack

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Sep 25, 2023
@melvin-bot melvin-bot bot removed the Overdue label Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

7 participants