Bob the Hobgoblin (Bobgoblin) wishes to surprise his troll friend Wally. Bobgoblin knows that if he stands in the middle of the room, Wally will automatically notice him and won't be surprised, so Bobgoblin decides to hide from Wally to achieve surprise. Bobgoblin finds a convenient hiding spot and hides. Bobgoblin rolls a Dexterity (Stealth) ability check to see how well he hides and readies his present. Since Bobgoblin is small, quick, and cunning, he's pretty good at hiding and ends up with a 17 hide check.
Wally the troll walks in. Wally's aware that it's his special day and that his friends like to throw surprise parties for him, so he's generally wary. He's looking around and paying attention today. So he doesn't have disadvantage on his passive perception for being inattentive. Wally's also the wisest of his friends, and is generally perceptive, so he notices things pretty well. He has a passive perception of 16. When Wally scans the room, however, Bobgoblin's superior hiding skills outmatch Wally's perception and Wally doesn't notice Bobgoblin.
Now, Bobgoblin springs his surprise! Since Wally wasn't aware of Bobgoblin at the start of initiative, Wally is surprised. He can't act on his first turn and cannot use reactions until after his first turn. Now both Bobgoblin and Wally roll initiative. Let's say that Bobgoblin beats Wally in initiative. Bobgoblin gets to go, yells 'Surprise!', and hugs Wally. Wally can't react to the hug, being surprised, and Bobgoblin succeeds in giving Wally a great big hug! Now it's Wally's turn, but he's still getting over his surprise, so he can't act. Next round, Bobgoblin goes again and presents Wally with his present. Wally can now react to the present, and does so with his "smile broadly" ability. It's now Wally's turn and he takes the present.
If, however, Wally had beaten Bobgoblin's initiative, then Wally would have the first turn. He would still be surprised, and so couldn't act on his first turn, but he'd now no longer be surprised and could use reactions. When Bobgoblin comes in for the hug on Bobgoblin's turn, Wally can react with by returning the hug.
Later on, Ogre Doug decides to also surprise Wally. Doug isn't as cunning or quick as Bobgoblin, though, so when he hides he only gets a 12 on his Dexterity (Stealth) ability check. When Wally walks in, still wary of surprises, his passive perception of 16 allows Wally to notice Doug. So, when Doug decides to jump out, Wally is not surprised, and everyone gets to act normally on their turns. Wally, though, being the awesome friend he is, decides to spend his turn acting surprised. He makes a Charisma (perform) check to gasp and look shocked. Ogre Doug, though, rolls a great Wisdom (Insight) check and realizes Wally's acting, but still really appreciates the gesture his friend made to make him feel better about his poor choice of hiding spots.