The game performs a special calculation to determine if a hidden Pokémon will be forced to be Shiny. This algorithm primarily depends on the Pokémon's Search Level, but may also be influenced by other factors. Note that even if the game does not force a hidden Pokémon to be Shiny, it may still naturally end up Shiny.
To check if a hidden Pokémon will be forced to be Shiny, the game compares a target value with a random number from 0 to 9,999, and if the random value is less than the target value, it will be Shiny. The target value depends on the Pokémon's Search Level. For every Search Level from 1 to 100, the base target value increases by 6 (starting from 0); for every Search Level from 101 to 200, the base target value increases by 2; and for every Search Level above 200, the base target value increases by 1. The target value is the base target value divided by 100. This means that a Pokémon with a Search Level of 100 has a target of 600 / 100 = 6; if its Search Level is 200, the target is 800 / 100 = 8; if its Search Level is 250, the target is 850 / 100 = 8.5. Since this is compared against a random number less than 10,000, this means that the chance of forcing a Shiny Pokémon starts at a miniscule 1/10000 of 6% at Search Level 1, and it increases by 0.01% after every 16 2/3 Search Levels up to 100 (reaching 0.06% at Search Level 100), after every 50 Search Levels up to 200 (reaching 0.08% at Search Level 200), and after every 100 Search Levels thereafter. By comparison, the natural chance of finding a Shiny Pokémon is approximately 0.024%; the chance to force a Shiny Pokémon only exceeds this after Search Level 40.
This check to force a Pokémon to be Shiny may be repeated multiple times. For any hidden Pokémon, this check is performed at least once. If a random number from 0 to 99 is less than 4, it will be performed four extra times. If the player has the Shiny Charm, the check will be performed two extra times. Finally, if the player is encountering their 50th Pokémon in a chained streak of hidden Pokémon, the check will be performed five extra times, or if they are encountering their 100th chained Pokémon, it will be performed ten extra times. These extra checks can stack, for a maximum possible number of 17 checks.
My source shows the exact odds in a helpful table, just below what I quoted.