Sharepoint 365, User has permissions but site shows no access to the site

You give a user permissions to access a site or add him to a group that has access to the Sharepoint site. 
But when the user tries to log in, the user is presented with the "You do have have permission" page and a button to request access. 

This is caused if the user had access before and it has been removed either by revoking his access of deleting his account. 
Sharepoint has issues clearing it's own permission cache so the old user still lingers around. 

Do the following to resolve this:

  1. Log in to the sharepoint site in question as an administrator
  2. Click on the cogwheel icon on the topright > Site Permissions Advanced permissions settings
  3. Click on either the member, owners or visitors groups, it doesn't matter which one you select
  4. In your address bar at the top you will see this: https://<tenant>/sites/<site>/_layouts/15/people.aspx?MembershipGroupId=4
    See the number at the end? Change that to a 0 and hit Enter
    You will get a list of all the users that had access to the site one way or another
  5. Find your user and then select it by putting a checkmark next to their name, then click Actions Delete Users from Site Collection
  6. Have your user close their browser and try to login into the site again, it should work now.