My 2013 XF Sportbrake had this before I bought it (cost of repair was just over £1000 at Jag indy according to paperwork).
No sign of water since I got it but as part of the fix they left a small drain hole open in the spare wheel well so hopefully if it did recur it would not be so expensive.
As belt and braces I have installed a battery operated flood alarm from ebay https://www.ebay.co.uk/itm/Water-Leak-Alarm-moisture-flood-high-level-detector-sensor-bath-sink-overflow-HG-/223037327521?hash=item33ee0f88a1 I have put the sensor in the deepest spot in the well and keep the alarm itself in the boot and just test every couple of weeks. The braces part is several silica moisture packs dotted around by the battery and suspension pump etc.
As part of repair, previous owner presumably cut a corner (cost) by replacing the AGM Main battery with a standard Lead-Acid battery which I have since replaced having read about the difference.