Earlier quoted context omitted.
Ukraine joining NATO has been a hotbutton topic for the last 10 years. It was decided 6 months before the invasion that it would Ukraine would join, and I don't the two facts are entirely unrelated.
You can't join NATO if you have an ongoing territorial dispute. Ukraine would have been unable to join while Crimea and parts of Donbass/Luhansk were occupied.
Prior to the war, Ukraine sought entry despite ongoing conflicts, claiming "NATO is the only way to end the war in Donbas".
Since the start of the war, Former US Ambassador to NATO and others have called for Ukraine to be offered membership, despite territorial conflicts.