Fixed a bug in the logic for calculating the threshold date of a task