In the beginning of Avengers: Infinity War couldn't they teleport someone to Earth sooner? When did they realize the ship belonged to Thanos?
If he did announce it early enough they could have teleported to Earth before Thanos attacked them. Was Loki willing to help his people?
If he was he could have revealed that he had the Tesseract and even though they didn't have the contraption they had in the first Avengers movie couldn't they use it as a group as in Guardians of the Galaxy?
Or give it to someone like Thor (or the Hulk, who in Endgame was shown to be very strong, if Loki was untrustworthy and Thor didn't want to leave his people, or maybe Heimdall) to go and warn Doctor Strange?
If they warned him early enough they could possibly have 4 Stones (the Tesseract, the Eye of Agamotto, Vision's Mind Stone and, since they knew where it was, the Reality Stone).