If you receive a spam message through Yahoo! Messenger, you can report it as spam. This will automatically add the sender's ID to your Ignore List, so you won't receive messages from that yahoo_user_id in the future. Reporting the spam message will also help Yahoo! SpamGuard Plus work better to reduce spam overall.
When you receive a message from someone who is not in your Messenger List, the conversation window will notify you: "user is currently not in your Messenger List." You'll also see two links, one to "Add to Your Messenger List" and another to "Report as Spam." To report the message as spam, click that link. You won't receive more IMs from that yahoo_user_id.
If the message from someone not on your Messenger List is from a person you want to add, click that link, and a message will be sent to that person asking permission for you to add to your Messenger List and asking to add you to the other person's list.
If the message is not spam, but you don't want to add the person to your Messenger List, you can just IM with that person without clicking either link.