We know he didn't almost lose on Titan.
Dr Strange checked a myriad of possible futures, and in none of them did they defeat Thanos on Titan and end the threat. If Thanos was "almost beaten" in any meaningful way, then some change in what the heroes did would have moved the result over to "beaten".
The most generous possibility is that they could have, at best, made Thanos retreat on Titan, then come back prepared and win anyhow.
This is relatively strong evidence that on Titan, Thanos was playing around with the heroes, and even if they pulled off the tricks like Mantis' sleep ability Thanos would have just taken the gloves off.
Thanos knows that these beings are competent enough to defeat one of his underlings, but not powerful enough to stop the underling from taking the stone in the first place. So he has a good idea of how tough they are. He probably also knows the Guardians of the Galaxy competence level, as they have interacted with his children and agents in the past.
Given that, it is plausible that Thanos believes that nobody here is likely to be a real threat to him. He can afford to act like a world class expert at a sport playing with people who aren't even professionals. This is backed up by Dr Strange's conclusion, that no tactic could win, and they best plan is to let him have the stones, fullfil his plan, win, then retroactively undo it after he is out of play. Finally, defeat him when he's younger, less prepared, and the heroes are better prepared, and only by not defeating him but rather by taking the complete infinity gauntlet and vetoing his existence.
By the time Thanos gets to Earth in Infinity War, he both knows that this isn't some backwater planet, but actually has people rivaling those he fought on Titan. He doesn't have time to play and enjoy himself. He has reached the end of his life goal. Finally, he could have used the Time Stone to spend as much time as he wants practicing with the stones, but we don't have proof of that other than his surprising competence with the time stone.