DROP POLICY IF EXISTS "Legal users can view legal matters" ON public.legal_matters; CREATE POLICY "Legal users can view assigned community legal matters" ON public.legal_matters FOR SELECT TO authenticated USING ( public.has_role(auth.uid(), 'legal'::public.app_role) AND public.legal_user_assigned_to_association(auth.uid(), association_id) );