I'm answering my own question in the unlikely event it helps someone else, although I suspect this odd behaviour could result from a number of possible hardware issues or a sensor error.
I started to suspect something wasn't quite right with the display so I connected the iMac to an external display and for the first time in about five days the computer booted up from the internal hard drive. Oddly enough both the internal screen and external screen worked fine while using the computer.
I then disconnected the external screen and the problem returned - the iMac would not boot from the internal drive. Reconnecting the external screen results in everything working fine. I went through this disconnect/reconnect process five times and the results were repeatable.
While connected to the external screen I was able to import and rebuild the corrupt mailbox with the end result being a 258 Gb reduction in the mailbox size!
As far as I can tell, both the LCD panel and the internal DisplayPort cable are fine, so I'm recommending to my friend that she run it connected to an external display for a while to determine if any other problems present themselves. While I could inspect and reseat internal DisplayPort cable, this is not something I intend to do unless she reports back that the internal display stops working.
I will update this answer if/when I have anything else useful to share.
[Update]
Eventually the iMac stopped booting altogether - only getting part of the way before restarting itself in an endless loop. Also the display would show vertical lines etc, so the owner bought another 27" model and gave me this to use for parts.
After having it in my office for a few months and not needing any of the parts, I decided to disassemble it to see if I could find any obvious fault. Nothing stood out at me so I decided that since I had gone to all this trouble, I may as well remove the GPU (an AMD Radeon HD 6970M 1024 MB) and bake it in the oven to try and re-flow the solder and heat the Bumps under the surface-mount chip. (Basically I had decided a while back that the GPU was the most likely culprit).
After doing this and reassembling everything the iMac booted up normally. It was the first time this year it had booted successfully! I've since rebooted it 30+ times, run Apple Hardware Test, and so on. Not sure how long this will last (the baking a GPU in the oven trick is often described as a temporary fix, but Ive heard of GPUs still working normally six months later.
For anyone who is interested, below is a brief summary of what I did:
- Disassemble the iMac enough to remove the GPU
- Set oven to 205℃ (400℉)
- Place a sheet of baking paper on an oven tray and place the GPU (only the GPU itself) on the oven tray
- Place it in the oven for 8 minutes
- Remove the tray and let it cool
- Remove any old heatsink compound from the chips and replace with new compound
- Reassemble everything
This process took me approximately 4.5hrs (including various interruptions along the way).
Obviously the steps above do not go into detail, so anyone reading this who feels confident enough to give it a go can post a comment below or in chat and I'd be happy to walk them through the process in greater detail.
Remember though, I've disassembled countless computers over the years, so if you haven't and still want to give this a go, please be patient and allow more time. Also, you will require some tools that you most likely won't have (but can easily purchase online).
Best Answer
Your iMac shipped with Catalina. Generally, Apple does not support using an OS older than what the device originally shipped with. Yes, there are the occasional exceptions. Unfortunately, your model is not one of them.
If you really need to run Mojave on your system, then you should probably consider running it within a virtual machine.