Answer :
They are both grammatically correct it is just that the former is using perfact past. As sited from Cambridge Grammar of the English Language "The preterite perfect [i.e. the past perfect] locates the writing anterior to an intermediate time which is anterior to the time of speaking - it is doubly anterior (140). "