IME it's just a balancing act. Sometimes you'll add fish & it'll all work out fine. Other times, all hell will break loose. I've also had experiences when it was all great for weeks/months - then one night, sh*t would hit the fan & I'd have dead fish.
You can do extensive research to find species that normally get along, but its not a guarantee. Also, having decor/plants in the tank to break lines of sight help. But be careful, because if you add caves/wood that allows fish to claim them as territory, you may run into issues.
Another thing to think of, if you have any fish that pair off - all hell will break loose. I personally liked to keep singles of species to avoid that possibility.