Fix filtering invalid tasks