Rather than using the logic in the best_name functionality. libnotify should be using the built-in functionality of pidgin. There is already a function purple_buddy_get_contact_alias which returns the correct alias.
The reason I found this is because the notification is returning the screenname rather than the Contact's alias which should have precedence.
The documentation for this function...
2009-08-03 22:16:40 UTC in gaim-libnotify