The correct option is D Had + been + verb (ing)
The past perfect continuous tense indicates an action of the past which was completed before another event takes place. Option D "S + had + been + verb (ing) + O" is the correct form of writing in the past perfect tense.
Option A is incorrect as 'has'have + V3" is written for the present perfect tense.
Option B is incorrect as 'had + V3" is written for the past perfect tense.
Option C is incorrect as 'had + been + V3' is not written for the past perfect continuous tense. The verb takes the ing form with had been in the past perfect continuous tense.
Thus, option D is the correct answer.