To emphasize an action that was in progress before another action, or time, in the past.
Sally had been working in her new job for two weeks when she found out she was pregnant.