First of all I'm sorry about your losses.
I don't know what the threshold is but your core temperature should stay relatively stable and not go up too high. A temp of 38.40 is definitely a fever but I'm not sure if it's high enough to cause a miscarriage. I do know that the RE I'm seeing for recurrent miscarriages has told me to stay away from hot yoga (where they heat the room) during the TWW and in case I get pregnant to be on the safe side, and pregnant women are advised to stay out of saunas. I have also read one of the home methods some women use to try to cause a miscarriage is to take a very very hot bath and to raise their internal temperatures. So it is possible but we couldn't know for sure that in this case that's what caused it. It's also possible that the flu infection on its own could cause it regardless of the temperature.
Or maybe it's the other way around, that an early mechanism associated with miscarriage caused your fever before you started spotting.
OR it could have been a huge coincidence..
You didn't mention how far along you were but what I've read said there's more evidence for fever causing a problem later on in the pregnancy, and the link is weaker in the first trimester.
Honestly there are so many possible causes out there (very sadly)