This is a tricky question made more difficult by the fact that the answer keeps changing as the government introduce new rules or update and vary the old ones as to when a Section 21 notice purporting to trigger the termination of an assured shorthold tenancy is valid. The government is supposed to be abolishing these notices altogether but as at 29 September 2019 when this was written they had not done so.
The best way to answer this question is to visit the Nearly Legal Flowchart page where you can go through the steps set out to establish whether particular notice might be valid.
For more information on the related subject of tenancy deposits visit the Justice of Tenants site
I have added this question because I had forgotten the answer myself when a client of mine who is staying in a refuge went to two different London Homeless Persons Units this week (ending 23 August 2019 ) to ask for assistance but was told that she was not homeless and needed a letter from the refuge requiring her to leave before she could be assisted by a council.
It has been established law since 2009 that women’s refuges are not to be treated as accommodation which is reasonable to continue to occupy and that women staying in such accommodation are entitled to be treated as homeless. This was decided by the Supreme Court in the case of Birmingham v Ali and Moran v Manchester  UKHL 36. Further the Code of Guidance states at paragraph 6.39 (b):-
“some types of accommodation, for example women’s refuges, direct access hostels and night shelters are intended to provide very short-term, temporary accommodation in a crisis and should not be regarded as being reasonable to continue to occupy in the medium and longer-term;”
This means that a woman is entitled to be treated as homeless if she is staying in a refuge and that the council staff should not have told my client that she could only be homeless when she was required to leave the refuge. They should also have processed the application and issued a Section 184 Notice rather than turning her away with only incorrect verbal advice.