Search role in web table and select it if exist

Hello again

I’m working in a process to delete roles for several users (500).
I did a process, but I’m seeing it isn’t working well. Only select the checkbox Role, if it is in the beginning.

I’ve created a dataTable, This DT contains base information with user_id, my key field to find this particular role and delete it.
In this process, I need to access each user to browse his roles. All roles change according to the user.

My problem is how can I browse the (web table) roles, find and select the correct role, through its checkbox.
Here an image with three cases

I’m a little confused. Please your help.
Thanks