Created a topic in a specific category with conditions

I tried this for users who have created a new Topic in a specific Category that satisfied some conditions.

SELECT DISTINCT ON (p.user_id) p.user_id, post_id, p.created_at granted_at
FROM posts p
INNER JOIN topics t
WHERE t.category_id = 99 AND p.post_number=1 AND  <conditions here> AND
  (:backfill OR IN (:post_ids) )