It is possible for a transaction the be invalidated when in the mempool: if 2 conflicting transactions are both rejected one of them is lastly pulled back to mempool where invalidation can happen. We need to make sure we remove such a tx from the mempool and not assume it's already been removed.
To do so we simply apply the same logic to rejection and invalidation, with the additional steps for invalidation.