SELECT *
FROM records_status rs
WHERE company_id = (
SELECT company_id
FROM customauth_user
WHERE
id = 4 AND
(
is_superuser = true OR
NOT (permissions ? CONCAT('records.', rs.key, '.denied'))
)
)