You're not wrong. I experienced it myself when I was still living in Toronto. Perfectly qualified, great reference from within the company and the team lead's pick following interviews - which overruled by HR. I got the full story from my buddy who referenced me.This was 3 years ago and the person selected didn't last a year.
I'm not mad in hindsight as I landed in an even better spot, with better pay, in a better location, but had I desperately needed that job it would have been devastating.
It's also worth noting just how...wrong that feels in downtown Toronto. There is no real "majority" population anymore. "Founding stock Canadians" or whatever you want to call us only make up ~40% of the population, likely far less by now. It was less than 50 as of 2015. You really have to wonder how low it needs to be before these practices stop.