Got Red Tag warning from gas company for hot water tank (Canada)
What size is the vent pipe. Most water heaters use a 3" or 4" flue pipe. If it is larger, and it does look larger than that in the pictures, you could resize it to the correct smaller size, which would yield a little more clearance. Also ask the gas company's inspector if you can replace that single wall pipe with double wall "B" vent of a smaller size (correct size) and also nail  a sheet of 5/8" fire-shield drywall to the butchered wood. Another thought, if the other flue pipe is the one to the left in the top picture, you could cut that pipe, install a pipe flue tee of the correct size and eliminate the flue pipe that is in question. You may need to hire a professional sheet metal person or HVAC company to perform this change since The pipe after the connection point would have to increased slightly.