This is a mis-truth which has been spread by Joe Rogan and his ilk. Political speech is very much protected in UK law. You won't get in "trouble" if you make posts against immigration or trans people. J.K. Rowling and Ricky Gervais certainly haven't been locked up.
Yes, there have been cases, such as the infamous Cowley Hill School case where Hertfordshire police arrested a couple over their posts in a school WhatsApp group. However, such arrests are illegal and in that case the police had to apologise and pay compensation.
What will get you in trouble in the UK is threatening violence against people or posting hate speech that encourages others to do so. But this is also true in the USA and in most countries.