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

Update Permissions for Copilots #52724

Closed
wants to merge 7 commits into from
Closed

Conversation

dangrous
Copy link
Contributor

@dangrous dangrous commented Nov 18, 2024

Explanation of Change

We weren't disallowing removal of copilots (other than the logged in copilot) or updating of copilot roles on the front end. They're already disallowed on the backend. This is "fixing" a server error, that was a good server error to throw - it helped us figure this out.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/444641

Tests

Same as QA

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  1. Add at least two copilots to an account
  2. Log in as one of the copilots
  3. Verify you are not able to update the role of any copilot (you see the screenshotted warning)
  4. Verify you cannot remove another copilot from the account (you see the screenshotted warning)
  5. Start the process to update a copilot's role from the original account, and copy the URL
  6. Paste that link into the copilot's session and verify you get a not found page.
  7. Continue the process on the original account (get to the magic code page) and copy the URL
  8. Paste that link into the copilot's session and verify you get a not found page.

Warning modal:
Screenshot 2024-11-18 at 15 50 01

  • 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 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 either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • 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 UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design 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

working on getting the rest of the platforms but figured I'd start the review process

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

Screenshot 2024-11-18 at 15 50 01

Screenshot 2024-11-18 at 15 50 18

MacOS: Desktop

@dangrous dangrous self-assigned this Nov 18, 2024
@dangrous dangrous changed the title update updatedelegaterolepage to not found if logged in and deeplinked Update Permissions for Copilots Nov 18, 2024
@dangrous dangrous marked this pull request as ready for review November 18, 2024 21:06
@dangrous dangrous requested a review from a team as a code owner November 18, 2024 21:06
@melvin-bot melvin-bot bot requested review from abdulrahuman5196 and removed request for a team November 18, 2024 21:06
Copy link

melvin-bot bot commented Nov 18, 2024

@abdulrahuman5196 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@dangrous
Copy link
Contributor Author

hey @abdulrahuman5196 ! I can either set up an App issue to handle your review here, or you can just approve and we can review internally, let me know which you prefer - thanks!

@abdulrahuman5196
Copy link
Contributor

hey @abdulrahuman5196 ! I can either set up an App issue to handle your review here, or you can just approve and we can review internally, let me know which you prefer - thanks!

Hi, @dangrous Not sure what you mean by here. If this is something I(C+) can review, I can review. Do let me know the steps, I haven't used co-pilots before. I am fine with whatever suits best for this issue.

@dangrous
Copy link
Contributor Author

yep, you can review! I was mostly concerned about payment in this case, since it's not an App issue. Do I just make one and assign you?

For setting a copilot, it's pretty easy! Create an account and validate it (sign out and back in again), go to Settings > Security, and there's "Add a copilot" at the bottom. Let me know if you need any other guidance!

@dangrous
Copy link
Contributor Author

bump on this review @abdulrahuman5196 - thank you!

@abdulrahuman5196
Copy link
Contributor

Hi checking now

@abdulrahuman5196
Copy link
Contributor

Got it. I was able get co-pilot working.

@dangrous Does this change also cover add co-pilot flow? If i copy paste the add copilot url from original account to the copilot account it is working. But the remove/update copilot flow is showing no page found as per the PR test steps.

Screen.Recording.2024-11-26.at.10.37.27.PM.mov

@dangrous
Copy link
Contributor Author

oh good call, I should block that one out as well!

@dangrous
Copy link
Contributor Author

dangrous commented Nov 26, 2024

Okay, I added AccessOrNotFoundWrappers to all the other delegate related pages so:

  • Selecting a Delegate
  • Entering a magic code
  • Choosing a role
  • Confirmation page

Can you help me double check that flow? I think that's all we need. (both that it doesn't work as a copilot but also that it DOES work for non-copilots)

@abdulrahuman5196
Copy link
Contributor

Hi, thanks for the update. I think this should be good.
Will check this again in my morning and approve if no further issues.

@abdulrahuman5196
Copy link
Contributor

Checking now

@@ -202,6 +206,28 @@ function SecuritySettingsPage() {
[delegators, styles, translate, personalDetails],
);

const onUpdateDelegateRoleButtonPress = useCallback(() => {
if (isActingAsDelegate) {
setIsNoDelegateAccessMenuVisible(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

@dangrous
Since we are not disabling the popover here and also after pressing okay, it is shown even after action taken.

Screen.Recording.2024-11-28.at.10.53.23.PM.mov

@dangrous
Copy link
Contributor Author

dangrous commented Dec 2, 2024

I think that's okay? Since potentially they could try the other option. I'm not sure, @Expensify/design what do you think we should do here? Should we hide the pop up menu after they click okay on the modal?

@shawnborton
Copy link
Contributor

I think it makes sense to show each time the user tries to take a restricted action.

@dannymcclain
Copy link
Contributor

@shawnborton I think the question is if the three-dot menu should close after they click Got it in the modal. Personally I think it does make sense to close it since those menus usually close when any click is made outside of them, but I don't feel super strongly if others feel we should leave it open.

@shawnborton
Copy link
Contributor

Ah my bad, I understand now. I agree with your thoughts above!

@dangrous
Copy link
Contributor Author

dangrous commented Dec 2, 2024

okay cool, I'll dismiss the pop up when we close the modal. Thanks!

@dangrous
Copy link
Contributor Author

dangrous commented Dec 3, 2024

popup will now be dismissed - ready for another review @abdulrahuman5196

@abdulrahuman5196
Copy link
Contributor

@dangrous Could you kindly fix the merge conflicts?

@dangrous
Copy link
Contributor Author

dangrous commented Dec 5, 2024

fixed the conflicts but the logic broke a bit, I need to figure out why - on (attempting to) close of the NoAccess modal, first the delegate menu closes, and you have to tap/click again to remove the noaccess one.

@dangrous
Copy link
Contributor Author

dangrous commented Dec 5, 2024

Oh I think maybe it's the focus trap that's part of the added PopoverMenu. Do you know if there's a way to override that? It doesn't look like there's any prop passed through PopoverMenu, though I could add that... Not 100% sure that's the issue... but maybe?

@abdulrahuman5196
Copy link
Contributor

I think we shouldn't close the popup via setShouldShowDelegatePopoverMenu in the DelegateNoAccessModal's onClose, instead we can just close it once the popup action is taken itself on onRemoveDelegateButtonPress, onUpdateDelegateRoleButtonPress. There is no point in having the popup open in background while DelegateNoAccessModal is in view. So the popup and the modal won't colide with each other.
@dangrous

@dannymcclain
Copy link
Contributor

There is no point in having the popup open in background while DelegateNoAccessModal is in view.

I agree with this—I like closing the menu when the action is taken instead of when the modal is closed. 👍

@dangrous
Copy link
Contributor Author

dangrous commented Dec 6, 2024

ah okay let me try that. Also a million more conflicts, too. Sigh.

@dangrous
Copy link
Contributor Author

dangrous commented Dec 6, 2024

Okay welp in investigating the conflicts - I found this, which was just merged. We might not need this PR at all. Sigh. I'm going to test fully but seems like it's doing the exact same thing

@dangrous
Copy link
Contributor Author

dangrous commented Dec 6, 2024

Okay yeah it's a little different but seems to work equivalently. I'm going to close this out - thank you for your expertise and sorry for your trouble!

@dangrous dangrous closed this Dec 6, 2024
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.

4 participants