The brief
This X5 came in with electrical trouble that traced back to careless work elsewhere: a technician at another workshop hadn't refitted a protective cover properly, so rain water had seeped in and flooded the battery compartment, and the water had reached and damaged vital electronic modules. A modern BMW packs control modules in places that are meant to stay dry, and the battery compartment is one of them. When water gets in there it doesn't just cause a temporary glitch, it corrodes contacts and shorts circuit boards, and once a module's internals are water-damaged it's done. On this car the tailgate control circuit board was rusted and damaged, and the engine control module's circuit board was contaminated too. Water-damaged modules don't recover, so they get replaced, coded to the car, and the cover that should have kept the water out put back properly.
The diagnosis
On the lift and on the scan the picture was clear: rain water had flooded the battery compartment through a protective cover left off, and the water had damaged the tailgate control circuit board, found rusted, and the engine control module's circuit board, contaminated. The rest of the car was sound once the damaged modules were accounted for. That's a replacement of the water-damaged modules, coded to this car, plus refitting the protective cover properly so water can't get back in, rather than trying to dry out and revive boards that were already corroded.
The work
The damaged tailgate control circuit board and the engine control module's circuit board were replaced with the correct genuine BMW units, each coded and programmed to this car so the network recognises them. The battery compartment was cleaned and dried, the corrosion dealt with, and the protective cover refitted properly so the area stays dry. The fault codes were cleared and every module checked talking to the rest. A road test confirmed the X5 running normally, every system working, the tailgate behaving, and no fault codes.
The outcome
The X5 running normally, every electrical system working, the tailgate behaving, no fault codes, and the battery compartment sealed against water again. The car went home put right. A cover left off is what caused all of this, so replacing the water-damaged modules, coding them in, and refitting the cover properly is the only way to leave a car after that, dry, sealed, and back to standard.