The correct answer is: had.

The landlord had just rented the apartment when I got there. This is because the action of renting the apartment is in the past, and it happened before the action of getting there.

  • Has is used to talk about actions that happen in the present or have just happened.
  • Have is used to talk about actions that happen in the present or have just happened with more than one person.
  • Had been is used to talk about actions that happened in the past and continued for a period of time.
  • Had is used to talk about actions that happened in the past before another action in the past.

In this case, the landlord had just rented the apartment when I got there. This means that the action of renting the apartment happened before the action of getting there. The landlord could not have rented the apartment after I got there, because the apartment was already rented.