It’s a long shot but if you are using a watch with optical hr then it might be writing that (poor quality) data to the file rather than your chest strap data. I had a similar problem where i did several rides without realising that my chest strap was out of battery because when one hr data stream cut out it automatically switched to the optical hr data. I only noticed when i got a similar flatlining hr graph during intervals.
What head unit/ device/ watch are you using?
It’s a long shot but if you are using a watch with optical hr then it might be writing that (poor quality) data to the file rather than your chest strap data. I had a similar problem where i did several rides without realising that my chest strap was out of battery because when one hr data stream cut out it automatically switched to the optical hr data. I only noticed when i got a similar flatlining hr graph during intervals.