[lib] Fix leaving thread logic
Summary:
The logic had a couple of issues:
- We weren't checking the timestamps when the viewer was leaving a top-level thread
- We were checking top-level thread membership of the viewer, which doesn't make sense because it is guaranteed
- We weren't removing non-viewer users from sidebars while leaving their parent thread
https://linear.app/comm/issue/ENG-9452/remove-user-from-sidebars-when-they-leave-a-parent-thread
Test Plan:
- Create a thick thread and a sidebar with two users. Leave the parent thread as one user and verify that the user was removed from both threads.
- Create a thick thread and a sidebar with two users. Log in as the same user on two devices. Open the sidebar on one device and leave the parent thread on the other. An alert about chat invalidation should appear and both threads shouldn't be visible in the UI.
Reviewers: kamil, inka
Reviewed By: inka
Subscribers: ashoat
Differential Revision: https://phab.comm.dev/D13614