As I recall (I have the BEV version, without REX) it's quite a complicated system. The petrol tank is pressurised all of the time other than when it is being filled, and the system has to depressurise before you can open the cap.
If the system detects that the tank is losing pressure, it will generate a fault code (apparently it carries out a pressure check each time the vehicle is put into drive-ready state). There are a few things that may be the cause - at the simplest maybe just the seal on the cap. Or at a more complex level, possibly the combined temperature and pressure sensor inside the tank. You may be able to get more ideas about the likely cause via an Internet search, but be aware that outside the US they will tend to use the term petrol or fuel rather than gas.