Had the almost exact same thing happen. They wanted me especially because of the knowledge from my previous company. 3 interviews. Then, riight before they were gonna give me a coding challenge, I got the "uhm akschually naww" email.
There's something especially soulcrushing about that. Makes you prefer the ghosting or the "we went with the better candidate" bullshit