This basically does the same as 63ac7287321a101c3f601eeb151be73154ef7720 but then for tasks.
This also reworks some of the logic due to the recently-removed `cancel-requested` task status.