I see nothing in https://en.m.wikipedia.org/wiki/Treaty_on_the_Final_Settlement_with_Respect_to_Germany that says NATO could not expand.
https://en.m.wikipedia.org/wiki/NATO–Russia_relations says
“The NATO-Russia Council (NRC) was created on 28 May 2002 during the 2002 NATO Summit in Rome”
By that date NATO had previously enlarged to include Hungary, Poland, and the Czech Republic.
So if Russia still had its nose out of joint over NATO expansion into former Warsaw countries, signing up for the NRC surely did not indicate that.
The current Russia / Ukraine war had its seeds in EU and Ukraine agreeing to free trade treaty which no doubt would have led to Ukraine joining the EU. Instead government of Ukraine reneged and its people protested, toppling government in favor of a pro EU regime. Russia then took Crimea, shot down a passenger jet, and invaded the rest of Ukraine.
Thus Russia’s attempt to conquer Ukraine has less to do with Ukraine possibly being in NATO and more to do with Russia fearing the reduced economic influence it would have on Ukraine.
As a member of the EU, Ukraine was on a path to a GDP that would eclipse Russia. This embarrassment would ultimately force Putin from power.
The State Department has surely mishandled Russian relations, and the U.S. and NATO invasion of Yugoslavia gave Russia an excuse to have its feelings hurt. But Stalin tried repeatedly to assassinate Tito, so forgive me if I am not so moved by Russia’s concern over NATO aggression toward a Slavic country.
If Yeltsin wasn’t a drunk, Russia might have turned out differently.