Numerous things:
HK was 'leased' out to Britain negotiated under the use of guns and thus was never really free. And never really separated from China but was loaned out.
Secondly HK has changed a lot. It is actually quite dependent on China for a lot of things. Water comes from Donguaan. Electricity from Daylia bay. Also a lot of the economy depends on bought citizenships. HK is not the HK of the past. If you go around Yeun Long, Tai Po there are massive industrial units. Whole city blocks devoted to manufacturing. These are now empty and dormant having moved north of the border.
As such HK's economy is based on finance (which is collasping), restricting land supply and related a housing ponzi scheme. The other sources of income are Mainland tourists. And selling citizenships to Mainland Chinese and property to keep the ponzi going.
So while the UN may well have recognised their bid for independence like with East Timor. The reality of such a move would probably have been pretty awful for the economy as the CCP would have been all business with them. I.e. Water from Donguaan? 5000% increase, electricity? 5000% increase. Whatcha gonna do?
The 50 year thing is a deal struck by Deng Xiaoping. Originally he wanted 100 years but agreed with Britain 50 years with an option to extend. The 50 years is a grace period. Ironically not for Hong Kong but for China. Deng wanted 50-100 years for Mainland China to catch up economically in living standards and politically with Hong Kong. Before proper open borders and full reunification. In the past ten years HK has merely just become a city with a lot of tall buildings in it with a colonial past. You stand in a major coastal city in China and it looks pretty similar.
A second thought is a lot of Chinese don't seem to give a damn about voting anyway. HK's recent 'elections' were restricted to a few 100 people instead of a universal sufferage system. Nobody really seemed to care much. As long as their lives remained the same no new taxes and that people were allowed to make money and own stuff. People seemed pretty muted about it. I do not claim however to port the view of every person in China or HK though and I could well be wrong.
By 2047 who knows what will have happened. The PRC has lasted 60 years. But the USSR only lasted about 70 years. But the CCP is quite clever and devious in its dealings to stay in power. 89 was a major turning point. But they dealt with it by sharing out the pie a bit more. The life span of the CCP is limited though as nothing lasts forever and there are some major social and economic problems which may well cause China to fracture again.
My own thought is that the CCP by 2025-2040 (if they last that long) will go Japan or Taiwan. In that Japan nominally is a democracy. But from the post war period 1950s-1990 Japan was effectively a one party state. The same government kept on getting re-elected to the Japanese Kokkai (parliment/diet) and thus it was a defacto one government system like China is now.
Taiwan was a nasty dictatorship till the mid 80s. They then changed to a voting system where they've had three elections I think, and the KMT which were the nasty dictators for 40 years. Are still the majority in power.
Thus even if the CCP go and give the popular vote it doesn't mean they will be booted out of power and can still engage in all the corruption they do even if ther eis voting. Like the politicians do in our western nations.