MinZ/MaxZ is calculated based on the player perspective, but if the resulting min/max is between -1 and 0, then the operation makes the orthogonal matrix smaller than player visible area, resulting in missing shadows, only on specific view angles + positions, as resulting frustum corner has to be (-1,0).
In the following part of the example: https://github.com/JoeyDeVries/LearnOpenGL/blob/a545a703f95893258d16dbe32f5ccbb6400fd213/src/8.guest/2021/2.csm/shadow_mapping.cpp#L703
MinZ/MaxZ is calculated based on the player perspective, but if the resulting min/max is between -1 and 0, then the operation makes the orthogonal matrix smaller than player visible area, resulting in missing shadows, only on specific view angles + positions, as resulting frustum corner has to be (-1,0).