Hurt feelings count, at least for the Enchantment School
Contrast this spell with other effects like Hypnotic Pattern (Illusion School), Dragon Fear (Racial Feat), or Turning Undead (Class Ability). In all of these cases, the condition that ends the effect is 'takes any damage' (not harm). Charm Person goes outside the normal schema, and in doing so indicates that 'harm' needs a more expansive definition than just damage, for otherwise that would have been used.
So what constitutes harm? Consider how the Enchantment School works: (PHB 115)
As a member of the School of Enchantment, you have honed your ability to magically entrance and beguile other people and monsters. Some enchanters are peacemakers who bewitch the violent to lay down their arms and charm the cruel into showing mercy. Others are tyrants who magically bind the unwilling into their service.
Note that the school is about 'entrancing and beguiling'. People's feelings of trust and loyalty are central to how it operates on the conscious mind. Thus, anything that harms trust counts as harmful for the purposes of this spell. My answer would be very different for a similar question related to, for example, an Abjuration school spell, where you would likely have to demonstrate that an attack did some game-effect damage to count as harmful.
Does an unsuccessful attack count as "harmful" for purposes of charm person?
Roger's attack on Tarley hurt Tarley's trust in Sophie. He thought she was his friend and ally, and she tricked and endangered him. That is certainly harm, precisely because he considers it harm.
Note that for each of the effects listed above that end when the target takes damage, damage from any source - friend, foe, or environment - counts. Charm Person, on the other hand, specifically says the target "is charmed by you until the spell ends or until you or your companions do anything harmful to it."
If a creature takes damage from a source other than the caster or their allies, the charm is not ended. If a goblin had slipped out of the bushes and fired an arrow at Tarley, even if the arrow had hit and done damage, that would not end the spell. It is reasonable to expect the spell to keep track of who the caster is, since that is the person Tarley has to be charmed by. But how does the spell 'know' who the caster's companions are? How is this first level spell keeping track of the the interpersonal relationships between Sophie and her adventuring partners, hirelings, mercenaries, and acquaintances and deciding which of them are her companions?
I think it rather more likely that it is not the spell itself somehow detecting what "Sophie's companion" means, but that that information is being supplied by Tarley's own beliefs. That is, Tarley doesn't think that the goblin ambusher is Sophie's companion, but he knows that Rodger is. Thus, when Rodger attacks him but misses, that counts as harm, whereas the actual wound from the goblin is immaterial. Again, the harm comes from Tarley's feeling of betrayal by Sophie.
Would it make a difference if Tarley remained unaware of the attack -- e.g., because (as happened here) the DM ruled him distracted by Sophie's riveting conversation?
To feel that betrayal, Tarley would have had to notice the attack. Tarley won't have hurt feelings over an attack of which he is completely unaware. That being said, 'being distracted' generally does not mean you do not notice people attacking you. It might have given Roger advantage on his attack, according to PHB (177):
In combat, most creatures stay alert for signs of danger all around, so if you come out of hiding and approach a creature, it usually sees you. However, under certain circumstances, the Dungeon Master might allow you to stay hidden as you approach a creature that is distracted, allowing you to gain advantage on an attack before you are seen.
But once Roger attacked, typically he would be noticed by Tarley. Consider the Skulker Feat (PHB 170)
When you are hidden from a creature and miss it with a ranged weapon attack, making the attack doesn't reveal your position.
For this feat to have any meaning, normally when you make an attack while Hidden, the target does notice you. And if a target notices even an attack that misses from a Hidden opponent, they will usually notice an an attack that misses from a foe that is not Hidden.