A user with full access to a Customer or Partner account, either by sharing or account ownership, receives the following error when trying to change ownership to a user with a different role:
“You don’t have permission to take that action on this record or related records.”
This would indicate that the running user does not have the ‘Manage Roles‘ permission at the profile or permission set level. Because there are active external users connected to the account that have roles, it is necessary to modify the external role to account for the change of the parent role. In order for this to work the user initiating the change in ownership needs the ability to manage the roles.
You can resolve this by either assigning the permission to the user at the profile level or granting access using permission sets. If that is not possible then the change in ownership would need to be performed by a user that already has the ‘Manage Roles‘ permission enabled.
If the current owner of the account and the new owner share the same role, the error will not occur and the change in ownership should be successful.