I think it depends strongly on where you are chatting with someone, and how the interaction started.
There are some places that are understood to be pick up places, where people go to meet potential partners - some types of bars and clubs, for example. Large mixer parties at college age can have a similar function. If someone chats you up there, it's a reasonable guess that they are interested in more than a platonic discussion, so in that case, spending hours talking to one person could easily and logically send the wrong message. Or if a random person comes up and strikes up a conversation on a flimsy pretext - yeah, there's a good chance they're trying to pick you up, and it shouldn't come as a huge surprise.
On the other hand, if you're talking to someone at after church coffee, or at a casual social event at a friend's house, or at a club or organization arranged around a hobby, then you can assume most of the people there are not participating as a way to find partners, and a conversation can be taken as just that. If you are trying to hit on someone there, you have to recognize that they might not realize this.
There are subtle things you can to if you think someone might be hitting on you, but you're not sure, and you don't want them to get the wrong idea. Mentioning your boyfriend is one of them. Drawing other people into the conversation is another - if you're trying to hit on someone conversationally, enlarging the conversational pool is counter productive, so it gives more of a friend vibe.
In Ted's case, it sounds like he's pretty clueless. He knew she had a boyfriend, the conversation involved her boyfriend and other people at various points, but he still though she was leading him on by talking to him. With the extra details, I think his approach is pretty unbalanced, if you're his main social contact, and his exposure to single women is solely through meeting people through you. How many single female friends do you actually have for him to try to pick up?