I'm assuming that the `not_released` scope should be the logical opposite of the `released` scope. If that's the case, then it should actually be `AND`, not `OR`:

```
scope :released, -> { joins(:assignment).where("status = 'Released' OR (status = 'Graded' AND NOT assignments.release_necessary)")}
# If released is either of the above conditions, then not_released should be neither scenario:
scope :not_released, -> { joins(:assignment).where("status != 'Released' AND (status != 'Graded' OR assignments.release_necessary)")}
```

Basically just swapping the `AND`s and `OR`s and negating the equivalencies.