S + had been + V-ing
Activity ongoing before another past action; duration in the past.
Often with for/since before a past simple event.
They had been waiting for two hours before the bus arrived.
Họ đã chờ hai giờ trước khi xe buýt đến.
He had been studying when the lights went out.
Anh ấy đang học thì mất điện.