I usually recommend the Case Owner feature for that - see the method on the ICase interface.
Sadly, the Case Owner feature applies only to cases currently in terms of visibility in the dashboards, we requested the adjustment for tasks in SUPPORT-749. (Edit: We just got notified that this will be fixed in the 10.0.31 release 🥳)
If the case would also suit your requirement, you can simply set the role as owner of the case (you can even remove it after the task is done if you only want cases visible which are in one particular state) and enable the case owner feature in the engine cockpit:
Configuration-> Variables-> Portal.Cases.EnableOwner -> true
This however implies that the role can see any task in the case details.
For more than one role, you'd define a container role for the visibility and link the other roles to it.
Hope that helps!