The correct option is A had been chatting
The past perfect continuous form of any verb is obtained by adding 'had been' to the base verb + ing. The verb in question is 'to chat'; for which the base/ root is simply 'chat'. Applying the above, we clearly get 'had been chatting', which is Option B) - the correct answer. A) is simply past continuous; C) is present perfect continuous and lastly, D) is past perfect.