を忘れてしまって

forgot …; ended up forgetting …

→ を
phrase Uncommon #13,374
forgot …; ended up forgetting … The particle を marks what was forgotten. しまって is the connecting form of しまう and can convey regret or that the forgetting happened unintentionally.
JA: 大切な約束を忘れてしまって、本当に申し訳ありません。
EN: I completely forgot about an important appointment, and I’m really sorry.

彼女は私に会ったことを忘れてしまっている。

She has forgotten that she ever met me.

宿題を忘れてしまって、すみませんでした。

I’m sorry I forgot my homework.

ええ、届いたのをお知らせするのを忘れてしまってすみません。

Yes, I'm sorry I forgot to let you know that it arrived.

現実を忘れてしまって怠惰なだけだ

I’ve simply lost touch with reality and become lazy.

— 惑星ソラリス (1972)