+
+ # If filtering by one or more head_uuid, and the current user has
+ # manage permission on those uuids, bypass the normal readable_by
+ # query (which doesn't match all can_manage-able items, see
+ # #18865) -- just rely on the head_uuid filters.
+ @filters.map do |k|
+ if k[0] == 'head_uuid'
+ if k[1] == '=' && current_user.can?(manage: k[2])
+ @objects = Link.unscoped
+ elsif k[1] == 'in'
+ k[2].select! do |head_uuid|
+ current_user.can?(manage: head_uuid)
+ end
+ @objects = Link.unscoped
+ end
+ end
+ end