Hey, I'm certainly not claiming my way is correct/best but here's how I personally would approach a simple state machine: A Simple State Machine - Wokwi Arduino and ESP32 Simulator
You're welcome to take this (and the button lib I wrote, which has debouncing built-in) and run with it if you like or just see how I've structured the code.