They are both grammatically correct it is just that the former is using perfact past. As sited from <span>Cambridge Grammar of the English Language "</span>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). "