Get value from jsonb_array
You can expand the array using jsonb_array_elements_text() with a lateral join in this way:

select 
    users.id, 
    role.name
from   
    users
join lateral 
    jsonb_array_elements_text(data-&gt;'role') r on true
left join 
    role
    on role.id = r.value::int


db&lt;>fiddle here