when you can checkmate but the piece is blocking the mate
How do I know WHEN to sacrifice
Yes @Laskersnephew, I think it must be this game that you're talking about
Nxg7 is a common enough sacrifice, but the real beauty of this is it's a double sacrifice (Bh6 immediatly after) and that typically you need 3 attackers, but in this case 2 is enough because g4 eventually allows both rooks to come into the attack. (After the 2nd sacrifice it seems white only has the queen and the bishop attacking)
As B1Z says, you usually count the number of attackers and defenders. In the starting position
black only has a knight on the kingside, and white has a few pieces pointed in that direction. That lets you know a sacrifice is worth considering even if the details are very hard to get right.
@llama36 and @B1ZMARK are absolutely CORRECT! If you sacrifice, you MUST know how to follow it up (till you mate the enemy king or get a game-winning advantage)... And yes, thank you for teaching me the thumb rules and points about Sacrificing that I had not learned yet.
Even if multiple chess authors were unable to solve this, if all of us get together and each suggests a point, we can definitely solve this unanswered (as-of-yet) question

That question is one that many famous chess authors have grappled with.
It is not reasonable to ask people in the forum to give you an answer to such a question.
/ https://www.chess.com/article/view/storm-your-opponents-chess-castle
I disagree. There is a simple answer to the question "how do I know when to sacrifice?". That answer is, "When it works!"
I can't. Too many branches in the tree.