The object of golf is a pretty simple one: get the golf ball in the hole in the fewest number of strokes possible. However, as any golfer could tell you, playing golf is a whole lot more complicated than that one-liner -- including defining when the golf ball is actually in the hole.
When most weekend warriors play golf, they're not thinking about the technicality of when the golf ball is actually considered to be in the hole under the Rules of Golf. If the ball goes in the cup, it counts. If the ball grazes the lip, or even goes part of the way down, many amateur golfers will call that good enough for their edification.
However, the Rules of Golf have a rather specific definition of when the golf ball is holed, as the Rules term it.
Under the Rules of Golf, the golf ball is holed or considered to be in the hole when the ball "is both at rest within the circumference of the hole and the entire ball is below the level of the lip."
So, that means a ball is not considered holed until the ball has stopped rolling around in the cup and has remained in the hole. A golfer shouldn't pluck their ball out of the hole until the ball has come to a rest, otherwise that would be a one-stroke penalty. The player then has to replace the ball on the lip of the hole or against the flagstick and then putt the ball in the hole.
If a player's ball goes in the hole -- either partially or entirely -- with the flagstick in, they must make sure the ball get to the bottom of the cup and comes to a rest without touching the ball. Golfers typically wiggle the flagstick around in its place to get the ball to a stop at the bottom of the cup. Then the golfer can take the ball from the hole, and it's considered in the hole.
In the odd circumstance where a golfer has a ball lodged against the flagstick and not at the bottom of the cup, then wiggles the flagstick and moves the ball out of the cup, the golfer then has to place the ball on the lip of the cup and stroke it in from there.
Under the Rules of Golf before 2019, these situations would really only apply to balls holed that started off the putting surface. Putts holed pre-2019 from the putting green with the flagstick in would result in a two-stroke penalty in medal play and a loss of hole in match play. Now, that's not the case.