I kind of suck at boolean algebra, but:
https://github.com/bitcoin/bitcoin/blob/37612099ec7314b15a07d8bac55161ed4e8e7491/src/rpc/rawtransaction.cpp#L1672


Unless I'm mistaken (which is highly likely) the whole thing can't work  (except the edge case where `permitsigdata=true` and you have no sig data) 
"  \"reqSigs\": n,    (numeric) The required signatures\n"
            "  \"addresses\": [   (json array of string)\n"
            "     \"address\"     (string) bitcoin address\n"
            "     ,...\n"
            "  ],\n"
            "  \"p2sh\",\"address\" (string) address of P2SH script wrapping this redeem script (not returned if the script is already a P2SH).\n"
            "}\n"
            "\nExamples:\n"
            + HelpExampleCli("decodescript", "\"hexstring\"")
            + HelpExampleRpc("decodescript", "\"hexstring\"")
        );
    RPCTypeCheck(request.params, {UniValue::VSTR});
    UniValue r(UniValue::VOBJ);
    CScript script;
    if (request.params[0].get_str().size() > 0){
        std::vector<unsigned char> scriptData(ParseHexV(request.params[0], "argument"));
        script = CScript(scriptData.begin(), scriptData.end());
    } else {
        
    }
    ScriptPubKeyToUniv(script, r, false);
    UniValue type;
    type = find_value(r, "type");
    if (type.isStr() && type.get_str() != "scripthash") {
        
        
        r.pushKV("p2sh", EncodeDestination(CScriptID(script)));
        
        
        if (type.get_str() == "pubkey" || type.get_str() == "pubkeyhash" || type.get_str() == "multisig" || type.get_str() == "nonstandard") {