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

[$250] Security - Unable to remove closed account from copilot #53785

Open
1 of 8 tasks
lanitochka17 opened this issue Dec 9, 2024 · 46 comments
Open
1 of 8 tasks

[$250] Security - Unable to remove closed account from copilot #53785

lanitochka17 opened this issue Dec 9, 2024 · 46 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Internal Requires API changes or must be handled by Expensify staff Reviewing Has a PR in review Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Dec 9, 2024

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


Version Number: 9.0.73-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause - Internal Team

Action Performed:

Precondition: copilot account B is added to account A. Account B was closed.

  1. Account A: go to Security
  2. Click on three dots near copilot account B
  3. Click on Remove copilot > Remove copilot

Expected Result:

Account B is remover from the list

Actual Result:

Account B is no removed from the list

Workaround:

Unknown

Platforms:

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

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Bug6689200_1733770674968.copilot_remove.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021866325124686695861
  • Upwork Job ID: 1866325124686695861
  • Last Price Increase: 2024-12-17
Issue OwnerCurrent Issue Owner: @mollfpr
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Dec 9, 2024
Copy link

melvin-bot bot commented Dec 9, 2024

Triggered auto assignment to @VictoriaExpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@Shahidullah-Muffakir
Copy link
Contributor

I couldn't reproduce it.

Screen.20Recording.202024-12-10.20at.201.mp4

@lanitochka17
Copy link
Author

lanitochka17 commented Dec 9, 2024

@Shahidullah-Muffakir please check again preconditions have been added:
Copilot account B is added to account A. Account B was closed.

@Shahidullah-Muffakir
Copy link
Contributor

@Shahidullah-Muffakir please check again preconditions have been added: Copilot account B is added to account A. Account B was closed.

Thank you, Yes I could reproduce it now.
It seems like a BE issue:

Screenshot 2024-12-10 at 3 46 26 AM

@VictoriaExpensify
Copy link
Contributor

Yeah this is an issue we should fix.

@VictoriaExpensify VictoriaExpensify added the External Added to denote the issue can be worked on by a contributor label Dec 10, 2024
@melvin-bot melvin-bot bot changed the title Security - Unable to remove closed account from copilot [$250] Security - Unable to remove closed account from copilot Dec 10, 2024
Copy link

melvin-bot bot commented Dec 10, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 10, 2024
Copy link

melvin-bot bot commented Dec 10, 2024

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

@mollfpr
Copy link
Contributor

mollfpr commented Dec 10, 2024

I agree this is a BE issue. The ND should send a pusher message to update the account.delegates to their delegators when closing an account. But this doesn't solve this issue, until the user re-login.

The other thing we can do in the ND is, call an API that contains fresh account data when the user opens the security page. It does solve the issue and the user does not need to re-login to get the correct delegate data.

@VictoriaExpensify We might need an internal engineer to choose the right path.

@daledah
Copy link
Contributor

daledah commented Dec 10, 2024

Proposal

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

  • The error message is not displayed when API encountered error.

What is the root cause of that problem?

  • In PR we already display the error message from server, but we didn't handle remove delegate case. The issue is just one of the cases the API throws error.

  • In here:

    errorFields: {
    removeDelegate: {
    [email]: null,
    },
    },

    so even if the request encountered an error, the error is always cleared.

  • Even when we remove the above logic, the error message still cannot be displayed since in here:

const addDelegateErrors = errorFields?.addDelegate?.[email];

we only display the errorFields?.addDelegate.

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

  • We need to remove:

errorFields: {
removeDelegate: {
[email]: null,
},
},

  • Then, need to consider displaying removeDelegate error as well. So:

const addDelegateErrors = errorFields?.addDelegate?.[email];
const error = ErrorUtils.getLatestError(addDelegateErrors);

can be:

                   const addOrRemoveDelegateErrors = errorFields?.addDelegate?.[email] ?? errorFields?.removeDelegate?.[email];
                    const error = ErrorUtils.getLatestError(addOrRemoveDelegateErrors);
                    const isAddError = !!errorFields?.addDelegate?.[email];
  • Last, we need to update onPendingActionDismiss:

onPendingActionDismiss: () => clearDelegateErrorsByField(email, 'addDelegate'),

                        onPendingActionDismiss: () => clearDelegateErrorsByField(email, isAddError ? 'addDelegate' : 'removeDelegate'),

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

What alternative solutions did you explore? (Optional)

@daledah
Copy link
Contributor

daledah commented Dec 10, 2024

I believe the issue here is that we fail to display an error message when the API to remove a delegate encounters an error. There are many scenarios where the API might throw an error, and this is just one of them—specifically, when the pusher doesn't update the account.delegates data after closing an account.

To address this, we should:

  1. Fix the pusher issue on the backend to ensure it updates correctly.
  2. Ensure that an error message is displayed when an error occurs, as we already implemented in this PR.

@mollfpr
Copy link
Contributor

mollfpr commented Dec 10, 2024

@daledah That's a good suggestion to fix the show error message, but I think the issue persists. The user still can't remove the copilot until re-login.

The pusher fix only solved the issue when the copilot closed their account.

@daledah
Copy link
Contributor

daledah commented Dec 10, 2024

Thanks, @mollfpr! Could you tag the relevant internal team here to provide the final decision? In my opinion, we can address the error message display and the pusher issue simultaneously.

Copy link

melvin-bot bot commented Dec 13, 2024

@mollfpr, @VictoriaExpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label Dec 13, 2024
@mollfpr
Copy link
Contributor

mollfpr commented Dec 17, 2024

@VictoriaExpensify Could you add the internal label? Thanks!

@melvin-bot melvin-bot bot removed the Overdue label Dec 17, 2024
Copy link

melvin-bot bot commented Dec 17, 2024

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

Copy link

melvin-bot bot commented Dec 20, 2024

@mollfpr, @VictoriaExpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label Dec 20, 2024
@muttmuure muttmuure moved this to MEDIUM in [#whatsnext] #quality Dec 23, 2024
Copy link

melvin-bot bot commented Dec 23, 2024

@mollfpr @VictoriaExpensify this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@mountiny mountiny removed the External Added to denote the issue can be worked on by a contributor label Dec 23, 2024
@mollfpr
Copy link
Contributor

mollfpr commented Jan 15, 2025

Yup, similar to that or OpenPaymentsPage!

Do we do anything like that for profile info yet?

We only have OpenInitialSettingsPage but it doesn't return any data related to account delegates.

@dangrous
Copy link
Contributor

dangrous commented Jan 21, 2025

Okay so I've made a draft command that the App will be able to call - OpenSecuritySettingsPage - that will return the following onyx update:

            [
                'onyxMethod' => Onyx::METHOD_MERGE,
                'key' => OnyxKeys::ACCOUNT,
                'value' => [
                    'delegatedAccess' => [up to date delegated access data],
                ],
            ],

Does that feel right? If so, are you up for making an App PR that calls that on opening the security page, and then I can test locally to see if that works out?

@dangrous
Copy link
Contributor

bump on this ^^ when you have a moment @mollfpr - thanks!

@melvin-bot melvin-bot bot added the Overdue label Jan 23, 2025
@VictoriaExpensify
Copy link
Contributor

Not overdue, waiting for @mollfpr to chime in

@melvin-bot melvin-bot bot removed the Overdue label Jan 24, 2025
@mollfpr
Copy link
Contributor

mollfpr commented Jan 24, 2025

@dangrous Yeah, the API looks right!

If so, are you up for making an App PR that calls that on opening the security page, and then I can test locally to see if that works out?

Sure! I'll open up a draft PR for you to test now.

@mollfpr
Copy link
Contributor

mollfpr commented Jan 24, 2025

@dangrous Here's the draft PR #55709

@dangrous
Copy link
Contributor

Perfect, thanks! Looks like BE is working well. Going to clean up that PR and get that merged, then we can move ahead with yours!

@dangrous dangrous added the Reviewing Has a PR in review label Jan 27, 2025
@dangrous
Copy link
Contributor

hey @mollfpr! That command is now live on staging, and ready to be tested with your PR

@mollfpr
Copy link
Contributor

mollfpr commented Jan 29, 2025

@dangrous Thank you! I'll try on my PR!

@dangrous
Copy link
Contributor

dangrous commented Feb 3, 2025

How's this one looking?

@mollfpr
Copy link
Contributor

mollfpr commented Feb 4, 2025

@dangrous I found a case that make the issue still reproduced.

While the account A is open the security page, it will show the account B as the copilot. Open the account B on other device and close the account. In this step the account B is still appear on account A and will fail if try to remove the account B from copilot.

I'm thinking to calling the API again when it happen, so it will update the copilot list. What do you think?

@dangrous
Copy link
Contributor

dangrous commented Feb 4, 2025

hrm, that's a pretty edge case for the front end... So you're thinking just recall OpenSecuritySettingsPage before calling RemoveDelegate? I think that breaks our 1:1:1 policy.

I could potentially update the backend to just "succeed" if the account is closed? Not sure what that would take but might be okay...

@mollfpr
Copy link
Contributor

mollfpr commented Feb 6, 2025

@dangrous Actually, after the remove delegate is failing.

I could potentially update the backend to just "succeed" if the account is closed?

I'm onboard with this idea!

@dangrous
Copy link
Contributor

Cool - backend PR with that change is in review! If a user tries to remove a delegate with a closed account, it won't error, and it'll queue an onyx update sending the updated delegatedaccess

@dangrous
Copy link
Contributor

Okay, that change is live on prod - let me know if we need to adjust anything else, @mollfpr

@mollfpr
Copy link
Contributor

mollfpr commented Feb 12, 2025

@dangrous Thank you! The test looks great and I'll finish the PR now.

@mollfpr
Copy link
Contributor

mollfpr commented Feb 12, 2025

@dangrous On second thoughts, I think we don't need ND PR. There's no error in removing the close account as described in the issue.

Screen.Recording.2025-02-12.at.23.25.49.mp4

@dangrous
Copy link
Contributor

I think we should still update the list on opening the security settings page, though - that'll provide the best experience, since it'll lessen the amount of times people even have to remove a delegate.

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Feb 15, 2025
@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Feb 15, 2025
@mollfpr
Copy link
Contributor

mollfpr commented Feb 15, 2025

@dangrous I open a new PR #56900

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. Internal Requires API changes or must be handled by Expensify staff Reviewing Has a PR in review Weekly KSv2
Projects
Status: MEDIUM
Development

No branches or pull requests

8 participants