BraveSearchEnginesPreferences.removePreferenceIfPresent was calling
getPreferenceScreen().removePreference(pref) unconditionally. That
only removes direct children of PreferenceScreen — when the target
preference is nested inside a PreferenceCategory (as send_web_discovery
is, inside currently_used_search_engines_category), the remove call
silently returns false and the toggle stays visible.
Users whose WebDiscoveryEnabled pref is managed by policy (e.g. Brave
Origin subscribers, enterprise admins) saw the toggle rendered and
greyed-out instead of being hidden entirely.
Fix: remove from the preference's actual parent group.
preference.getParent() returns the containing PreferenceGroup — the
PreferenceCategory for nested prefs, the PreferenceScreen itself for
top-level prefs. Works for both cases.
Other PREF_CUSTOM_SEARCH_ENGINES_CATEGORY caller is a top-level
PreferenceCategory; new behavior is equivalent for that case.
Resolves: https://github.com/brave/brave-browser/issues/54751