Hi, Beth, ovulation happens in an instant, not for five days. Your app might have been projecting a likely range of when you might get pregnant based on the longer life of the sperm, but the egg itself pops out of the ovary (that is what ovulation is) and then is only viable 24-36 hours if it is not fertilized. Sperm, however, can last 4-6 days in your body. (That's where most apps get the length of time they give for a conception time period -- if you had sex 4 days prior to when your ovulate, the sperm could be waiting and ready.)
How far along did they say you were in weeks GA (gestational age) when you got the "dating ultrasound?" Was it super early in your pregnancy (such as, the 6th or 7th week)?
I did read what you said about the test at the hospital. But was it a urine-based test or a blood test? Did it happen first thing in the morning, before you peed or drank any fluids?
What you are trying to determine is the chance that sperm from the 24th lasted until the 3oth and got you pregnant around then (if that is when you ovulated). This would be a rather early ovulation compared to what you think happened from your app, but apps are only based on averages, and women don't always ovulate when apps think they will. The first guy's sperm would not need to last longer than normal to get you pregnant around the 30th. If that is what happened, the 13th would have been only 2 weeks from conception.
If the pregnancy test at the hospital was urine-based, although there are ultra-sensitive home tests that can catch a pregnancy two weeks after conception, the kind of urine tests used at hospitals often aren't that sensitive. (They're more like the kind where you have to miss a period before the test will detect the hCG.) This would have meant that the test on the 13th could be a false negative.
Anyway, while a negative test on the 13th and your app telling you that your likeliest time to have sex in order to get pregnant began on the 5th both suggest (to some extent) that the sex on the 24th didn't produce the pregnancy, a blood-based test on the 13th would have been more certain than a urine-based test for this purpose. If your early pregnancy test at the hospital was from a blood draw, you can rely on it. But if it was urine-based, I'd almost suggest you ignore the pregnancy test entirely (especially if it was not done with concentrated urine), and look at different evidence.
When you had your first ultrasound, was that when they said you were 14-15 weeks along, or did you have an earlier ultrasound? Especially, what estimated due date did they give you, based on an ultrasound and not on when your last period was?
Here is the problem. The 5th is too early for you to ovulate and then get pregnant on the 10th. The egg does not last that long. But also, a 14th-15th week ultrasound has a margin for error of more than a week if used to try to determine when conception was. Some doctors would say it has a 2-week margin for error.
It is often more useful to use your estimated due date from an ultrasound to try to figure this out, but even that won't be very accurate because your ultrasound was not early enough to be very precise.
Thanks for mentioning that you had a period that began on July 27. (I assume you know this for a fact and the doctor didn't just calculate that you must have had one around then?)
If you had a period on July 27, it means two things. One is, you were not ovulating on July 24. It would have been more like around July 13. Women ovulate two weeks before the next period, not 3 days before it. And the other is, you weren't pregnant. A period arriving indicates "not pregnant."
Based on you having had a period after sex with the other guy, and also on when you ovulated in the previous month, it sounds like you did ovulate on the (9th or) 10th. The pregnancy test could be explained away and the ultrasound was too late for the precision measurement you would like, but your period makes clear that you didn't get pregnant from the guy on the 24th.