Fix 500 error when "related_territories_id" is None