Refine the check for writing into the history db. If the status is PENDING - write no matter what the value of task.status is - since it's the default value