If you have advantage, OR if you do not have disadvantage (as in, you are making a straight roll, regardless of what ever other factors may be involved), and you have an ally that threatens the target (not incapacitated) within 5 feet, then you should get your sneak attack.

The way the game processes Sneak attack, however, causes it you check the condition at the wrong time - so that if there is ANY source of disadvantage affecting the roll, at all, it does not permit your sneak attack; this is incorrect.

It has always been like this, and it has never been fixed, despite countless reports. A few patches ago they updated sneak attack so that it errors and won't work, rather than just making a normal attack, so this bug became more visible for more people, but it still has not been fixed.

If your situation is that you are hidden (advantage), but at long range (disadvantage), and you have an ally threatening your target, then you have neither disadvantage, nor advantage, and are making the attack with a normal, straight roll - so you SHOULD be able to apply sneak attack if you hit.