Do NOT under any circumstance book a flight which has transit at Heathrow Terminal 5 with the connecting flight leaving the following morning if you do not have a visa and you are a citizen of a nation whose nationals are mandated to have a visa/transit visa when entering/passing through U.K.
On March 15 2017 I was detained together with a female Canadian permanent resident among others at Heathrow Terminal 5. She was there before I arrived and explained to me her flight arrived the previous night with connection the following morning at 16:00 GMT, basically she had a 15 hour layover which lasted overnight. I overhead her conversation with the I/O so I know her story to me was true.
Around midnight, the Terminal was to be shut down and she was asked to exit the airside and cross immigration. Her request to remain there was not accepted. She was administratively designated (to her objection) as someone who made an application for leave to enter the UK, and was of course refused, and detained. Now her flight was at 16:00 the following afternoon so you would think she would be released at 8:00 in the morning when the Terminal reopened. NO! They were going to hold her till boarding time and then she would be escorted (like a criminal) to the plane by immigration agents with her documents handed to the pilot to be returned to her upon arrival at her destination.
It even got worse, snow storms on the East Coast of the USA/Canada forced cancellations of many cross Atlantic flights on that day so her departure date was no longer known. After being held for 24 hours at the temporary detention facility in Terminal 5 (which has a 24 hour maximum hold time), by the time I was leaving/released she was being processed to be moved over to a permanent detention facility until a flight was obtained for her. She was bawling her eyes out and it was a sad sad tragedy however I could only comfort her so much under the circumstances.
Bottom line do not take an overnight connecting flight through Terminal 5 if you do not have prior clearance to enter the U.K.