The reason this thought experiment doesn't really work is that it disregards a crucial piece of information that the CCP is an authoritarian regime, while the people of Hong Kong are liberal and democratic. People generally prefer to move from the former to the latter, and not from the latter to the former.
I think history is useful, but it doesn't really change the fact that the people of Hong Kong do not want authoritarianism. It should be irrelevant what some king in the Qing dynasty or British empire did. As common folk ourselves, we should be giving more value to the will of the people, than the will of people who buy and sell countries and its people as if it was private property. So, no, Hong Kong does not "belong" to CCP just because at some point it "belonged" to Qing dynasty.
Talking about people as if they are property of kings and rulers is just slavery at the level of groups.