The past perfect tense expresses an action in the past that ended before another action in the past. In short, it is “the past in the past” action. :P

Past Perfect timeline

Past Perfect timeline

One action happens before another in the past

SCENARIO:
You’re now at the bus station but the bus isn’t there anymore, so you ask the porter. He informs you that the bus is gone. He says:

  • The bus has just left when you arrived. – [The porter is saying it now.]

Later, you go home and tell this to your mom:

  • Mom, the porter said that the bus had just left when I arrived.

Use “had” followed by the past participle form of the verb when you write a sentence in the past perfect tense.