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

Add possibility to leave from workspaces and workspace expense chats #35671

Merged
merged 53 commits into from
Apr 15, 2024

Conversation

rezkiy37
Copy link
Contributor

@rezkiy37 rezkiy37 commented Feb 2, 2024

Details

The PR introduces a couple flows for leaving a workspace and a workspace chat. It is based on rules that described here for these scenarios.

Fixed Issues

$ #35286
PROPOSAL: N/A

Tests

Leaving a workspace

  1. A current user shouldn't be a creator or an admin of a workspace you want to leave.
    1.1. So invite the user from another account to a workspace. You can do it via the workspace settings members page.
  2. Open the workspaces page.
  3. Hover on a "three dots" button on a workspace.
  4. Verify that there is a button "Leave" for a workspace that satisfies the 1st point.
  5. Click on the button.
  6. Verify that the workspace has gone from the list.
  7. Verify that the #announce room has been archived.
  8. Verify other related chats have been archived.

Leaving a workspace chat

  1. Login with user A
  2. Create or join a workspace if not done previously.
  3. In user A expense chat, mention user B and click invite them on the whisper message (user B shouldn't be an admin or a direct member (default) of the workspace chat you want to leave).
  4. Login with user B
  5. Open the workspace chat page.
  6. Hover on a "three dots" button on a header.
  7. Verify that there is a button "Leave" for a workspace that satisfies the 1st point.
  8. Click on the button.
  9. Verify that the workspace chat has gone from the LHN.
  • Verify that no errors appear in the JS console

Offline tests

Same as "Tests".

QA Steps

Same as "Tests".

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android.Leave.Workspace.mp4
Android: mWeb Chrome
Android.Chrome.Leave.Workspace.mp4
iOS: Native
IOS.Leave.Workspace.mp4
iOS: mWeb Safari
IOS.Safari.Leave.Workspace.mp4
MacOS: Chrome / Safari
Chrome.Leave.Workspace.mp4
Leave.mp4
MacOS: Desktop
Desktop.Leave.Workspace.mp4

@MonilBhavsar
Copy link
Contributor

@rezkiy37 can we please resolve this conflicts 🙏

@rezkiy37
Copy link
Contributor Author

@MonilBhavsar, you can try to use this PR for the testing.

@rezkiy37
Copy link
Contributor Author

Update - #35286 (comment).

@MonilBhavsar
Copy link
Contributor

There are some conflicts to resolve and @rayane-djouah looks like last bug is not reproducible. Can you please take a look?

@rayane-djouah
Copy link
Contributor

Bug: endless LeavePolicy requests after logout and logging back:
Recording.2024-04-10.231629.mp4

Sorry, I need more context on how to reproduce the bug. Also, I don't see any specific configuration for this request. Is it a common bug across the app?

I'm not able to reproduce.

Copy link
Contributor

@rayane-djouah rayane-djouah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and tests well 🚀

@melvin-bot melvin-bot bot requested a review from MonilBhavsar April 12, 2024 16:24
Copy link
Contributor

@MonilBhavsar MonilBhavsar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good overall


// Currently, we only render messages when members are invited
const verb = isInviteAction ? Localize.translateLocal('workspace.invite.invited') : Localize.translateLocal('workspace.invite.removed');
let verb = Localize.translateLocal('workspace.invite.removed');

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - 7321ad2.

);
}

function isInviteMemberAction(reportAction: OnyxEntry<ReportAction>) {
return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.INVITE_TO_ROOM;
}

function isLeaveMemberAction(reportAction: OnyxEntry<ReportAction>) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function isLeaveMemberAction(reportAction: OnyxEntry<ReportAction>) {
function isLeavePolicyAction(reportAction: OnyxEntry<ReportAction>) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - 7321ad2.

@@ -960,6 +974,101 @@ function removeMembers(accountIDs: number[], policyID: string) {
API.write(WRITE_COMMANDS.DELETE_MEMBERS_FROM_WORKSPACE, params, {optimisticData, successData, failureData});
}

/** Leave a workspace */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this. name implies the reason

Suggested change
/** Leave a workspace */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - 7321ad2.

Copy link
Contributor

@MonilBhavsar MonilBhavsar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Let's ship it

@MonilBhavsar MonilBhavsar merged commit 2ce785c into Expensify:main Apr 15, 2024
18 checks passed
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/MonilBhavsar in version: 1.4.63-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@MonilBhavsar
Copy link
Contributor

@rayane-djouah @rezkiy37 there were just this two backend bugs to fix #35671 (comment), right?

@rayane-djouah
Copy link
Contributor

@MonilBhavsar, Yes!

@MonilBhavsar
Copy link
Contributor

Thank you for confirming!

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 1.4.63-21 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@MonilBhavsar
Copy link
Contributor

@getusha @rezkiy37 this is the exact issue we discussed here, right?
#35671 (comment)
#40417

@MonilBhavsar
Copy link
Contributor

and as per the security guidelines, a non workspace member can join the workspace chat https://github.com/Expensify/App?tab=readme-ov-file#security. So I think we should update both frontend and backend to allow anyone to rejoin the chat. What do you think?

@rezkiy37
Copy link
Contributor Author

rezkiy37 commented Apr 26, 2024

and as per the security guidelines, a non workspace member can join the workspace chat https://github.com/Expensify/App?tab=readme-ov-file#security. So I think we should update both frontend and backend to allow anyone to rejoin the chat. What do you think?

Can we create an issue for this or do you want to fix it in a scope of the current issue?

@rezkiy37
Copy link
Contributor Author

Hey!
I just wanted to let you know about my vacation for next week. I will be back on 06.05.2024. Meanwhile, I asked @waterim to take over this issue.
See you soon!

}

if (report?.errorFields?.notFound) {
Report.clearReportNotFoundErrors(report.reportID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right to me. Why is this needed? @rezkiy37

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arosiclair, please check the condition above. The app checks if a report has reportID, if yes it means that the notFound error is not relevant anymore.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not necessarily true. If you lose access to a report,report.errorFields.notFound will be set along with the rest of the report data including the reportID.

So why is this needed? errorFields.notFound should already be cleared in the successData for OpenReport.

Copy link
Contributor Author

@rezkiy37 rezkiy37 Jun 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a bug - #35671 (comment). I fixed it - #35671 (comment), #35671 (comment).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay it sounds like the notFound error is not cleared when we push reports to users. I think we can just fix that on the backend. Do you know which API command you were testing that caused that bug? cc @MonilBhavsar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like InviteToRoom

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright looks like we just need to update Report::structureReportForOnyx to clear errorFields.notFound. I opened an issue to clean this up here.

@@ -165,6 +170,14 @@ function WorkspacesListPage({policies, allPolicyMembers, reimbursementAccount, r
});
}

if (!(isAdmin || isOwner)) {
threeDotsMenuItems.push({
icon: Expensicons.ChatBubbles,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi 👋 coming from #46248.

Pretty minor issue and part of the polish issue. We should be using the Exit icon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants