Wireless local area networks (WLANs) empowered by IEEE 802.11 (WiFi) hold a dominant position in providing Internet access thanks to their freedom of deployment and configuration as well as affordable and highly interoperable devices. The WiFi community is currently deploying WiFi 6 and developing WiFi 7, which will bring higher data rates, better multi-user and multi-AP support, and, most importantly, improved configuration flexibility. These technical innovations, including the plethora of configuration parameters, are making next-generation WLANs exceedingly complex as the dependencies between parameters and their joint optimization usually have a non-linear impact on network performance. The complexity is further increased in the case of dense deployments and coexistence in shared bands. While classic optimization approaches fail in such conditions, machine learning (ML) is well known for being able to handle complexity. Much research has been published on using ML to improve WiFi performance and solutions are slowly being adopted in existing deployments. In this survey, we adopt a structured approach to describing the various areas where WiFi can be enhanced using ML. To this end, we analyze over 200 papers in the field providing readers with an overview of the main trends. Based on this review, we identify both open challenges in each WiFi performance area as well as general future research directions.