As Miniman's answer points out, you cannot grapple as an opportunity attack because an opportunity attack does not give you an Attack action. However, your situation doesn't actually call for an opportunity attack. Instead, it sounds like you had readied an action. From Basic Rules page 72:
Sometimes you want to get the jump on a foe or wait for a particular circumstance before you act. To do so, you can take the Ready action on your turn so that you can act later in the round using your reaction.
First, you decide what perceivable circumstance will trigger your reaction. Then, you choose the action you will take in response to that trigger, or you choose to move up to your speed in response to it...
When the trigger occurs, you can either take your reaction right after the trigger finishes or ignore the trigger. Remember that you can take only one reaction per round.
When you ready an action, you declare that you intend to do something out of your turn in response to something specific happening. For example, you can ready an action by saying "If an enemy comes through that door, I will fire an arrow at them." If an enemy does come through the door, you can then immediately use the readied action and shoot them.
Therefore, if you state on your turn, "I want to grapple the gnome if he tries to get past me," and you have not taken another action on your turn, you would be able to grapple the gnome as he moves past you. If the gnome doesn't try to get by you, the action is wasted. You can also choose to ignore the trigger and take an attack of opportunity as your reaction instead.
Keep in mind that you must declare a Ready action on your turn. Ready actions are actions, like attacks or casting spells. If your turn had already passed when you declared you'd grapple the gnome, your DM would be right in ruling that you can only make an attack. However, if you declared it on your turn, and hadn't already attacked or acted, your DM should have allowed you to grab the gnome.
Yes, if the second Goblin is not within the Reach of the thing making the opportunity attack
It seems a bit weird, however the criteria for triggering an opportunity attack are:
- You are moving out of the reach of a hostile creature
- This movement is from one of your Actions, Bonus Actions, Movement or Reaction
- You have not taken the Disengage action
- You are not Teleporting
For this question we can discount Point 4, as the Goblin Boss can't teleport.
We'll also ignore Disengaging for now.
For Point 2, the movement is by the Goblin Boss' Reaction, which fulfills that criteria
For Point 1, if the swapping with the second Goblin does not cause the Goblin Boss to leave the Reach of any hostile creature, it will not trigger an Opportunity attack. In the diagrams below, the first set of movement will not trigger an opportunity attack, while the second set will.
EG -> EB
B G
EBG -> EGB
E - Enemy;
G - Goblin;
B - Goblin Boss
Note that wherever the second Goblin is moved from, it does not trigger an Opportunity attack from anything as its movement is forced by the Goblin Boss.
As for using Disengage (via Nimble Escape), it only stops OAs for the rest of your Turn, not the entire Round.
So, if someone had Readied an action to hit the Goblin Boss when the Boss did a specific thing, then the Goblin Boss did that thing on the Boss' turn, and in Reaction the Boss used Redirect Attack, that would not trigger an OA, wherever it moved, as it is still the Boss' Turn so Disengage is still in effect. But normally, Disengage would not help for this.
Best Answer
As you said, an Opportunity Attack requires that one be able to see the target. While other senses can count as "seeing" in some circumstances, the rule is specific that it must be "a hostile creature that you can see", and that is what it means.