Repository: Significant-Gravitas/Auto-GPT
File: autogpt_platform/frontend/src/components/CustomNode.tsx (TypeScript)

Code before:
      case "completed":
        return "bg-green-200";
      case "running":
        return "bg-yellow-200";
      case "failed":
        return "bg-red-200";
      case "incomplete":
        return "bg-purple-200";
      case "queued":
        return "bg-cyan-200";
      default:
        return "";
    }
  })();

  const hasAdvancedFields =
    data.inputSchema &&
    Object.entries(data.inputSchema.properties).some(([key, value]) => {
      return (
        value.advanced === true && !data.inputSchema.required?.includes(key)
      );
    });

  const inputValues = data.hardcodedValues;

  const isFilterMatch = (costFilter: any, inputValues: any): boolean => {
    /*
      Filter rules:
      - If costFilter is an object, then check if costFilter is the subset of inputValues
      - Otherwise, check if costFilter is equal to inputValues.
      - Undefined, null, and empty string are considered as equal.
    */
    return typeof costFilter === "object" && typeof inputValues === "object"
      ? Object.entries(costFilter).every(
          ([k, v]) =>
            (!v && !inputValues[k]) || isFilterMatch(v, inputValues[k]),
        )
      : costFilter === inputValues;
  };

  const blockCost =
    data.blockCosts &&
    data.blockCosts.find((cost) =>
      isFilterMatch(cost.cost_filter, inputValues),
    );

  const LineSeparator = () => (
    <div className="bg-white pt-6">
      <Separator.Root className="h-[1px] w-full bg-gray-300"></Separator.Root>
    </div>
  );

Review comment (suggestion):
```suggestion
  const isCostFilterMatch = (costFilter: any, inputValues: any): boolean => {
```

Code after:
      case "completed":
        return "bg-green-200";
      case "running":
        return "bg-yellow-200";
      case "failed":
        return "bg-red-200";
      case "incomplete":
        return "bg-purple-200";
      case "queued":
        return "bg-cyan-200";
      default:
        return "";
    }
  })();

  const hasAdvancedFields =
    data.inputSchema &&
    Object.entries(data.inputSchema.properties).some(([key, value]) => {
      return (
        value.advanced === true && !data.inputSchema.required?.includes(key)
      );
    });

  const inputValues = data.hardcodedValues;

  const isCostFilterMatch = (costFilter: any, inputValues: any): boolean => {
    /*
      Filter rules:
      - If costFilter is an object, then check if costFilter is the subset of inputValues
      - Otherwise, check if costFilter is equal to inputValues.
      - Undefined, null, and empty string are considered as equal.
    */
    return typeof costFilter === "object" && typeof inputValues === "object"
      ? Object.entries(costFilter).every(
          ([k, v]) =>
            (!v && !inputValues[k]) || isCostFilterMatch(v, inputValues[k]),
        )
      : costFilter === inputValues;
  };

  const blockCost =
    data.blockCosts &&
    data.blockCosts.find((cost) =>
      isCostFilterMatch(cost.cost_filter, inputValues),
    );

  const LineSeparator = () => (
    <div className="bg-white pt-6">
      <Separator.Root className="h-[1px] w-full bg-gray-300"></Separator.Root>
    </div>
  );