1)
If it's just that submenu then you can use:
$iif(!$dialog(XNotify), XNotify)


If there's more to the menu at the root level then it would be much cleaner to use groups. eg.
Code:
#xnotify off
menu * {
  ...
}
#xnotify end

and simply /enable & /disable on dialog close and open respectively.

2)

This is some code in desperate need of variables:
Code:
alias -l block {
  if !$isid {
    var %item = $replace($1-3, $chr(32), .)
    var %value = $gettok(%item, -1, 44)
    var %on = $iif($2, on $gettok(%item, -2, 44))
    var %parens = $iif($3, $chr(40) 1 $chr(41))
    .hadd -m $hsh(XNotify) %item $iif(!$hget($hsh(Xnotify),%item), %value)
    echo -a %value %on %parens $iif(!$hget($hsh(XNotify),%item),Un-) $+ Blocked from XNotify
  }
  else {
    return $iif($hget($hsh(Xnotify),$+($1,.,$2,.,$3)),$v1,$iif($hget($hsh(Xnotify),$+($1,.,$2)),$v1,$iif($hget($hsh(Xnotify),$1),$v1,$false)))
  }
}


I did this in a hurry so I didn't have time to test it or take a look at the final line (where $isid is $true), however I think the point you can take is this: Use variables with simple expressions instead of trying to evaluate everything all on one line - you'll be doing yourself a huge favour.