diff --git a/benefit-finder/package-lock.json b/benefit-finder/package-lock.json
index c812c1828..fdf425721 100644
--- a/benefit-finder/package-lock.json
+++ b/benefit-finder/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "benefit-finder",
- "version": "0.4.0.beta.1",
+ "version": "0.4.1.beta.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "benefit-finder",
- "version": "0.4.0.beta.1",
+ "version": "0.4.1.beta.1",
"hasInstallScript": true,
"dependencies": {
"@uswds/uswds": "^3.8.1",
diff --git a/benefit-finder/package.json b/benefit-finder/package.json
index f2decd28a..4c59003bb 100644
--- a/benefit-finder/package.json
+++ b/benefit-finder/package.json
@@ -1,6 +1,6 @@
{
"name": "benefit-finder",
- "version": "0.4.0.beta.1",
+ "version": "0.4.1.beta.1",
"private": true,
"engines": {
"node": "20.x.x"
diff --git a/benefit-finder/src/App/__tests__/__snapshots__/index.spec.jsx.snap b/benefit-finder/src/App/__tests__/__snapshots__/index.spec.jsx.snap
index af7a2506a..30b9f84ac 100644
--- a/benefit-finder/src/App/__tests__/__snapshots__/index.spec.jsx.snap
+++ b/benefit-finder/src/App/__tests__/__snapshots__/index.spec.jsx.snap
@@ -12,7 +12,7 @@ exports[`loads intro 1`] = `
getValue('field_b_has_child');
+
+ if ($has_child['value']) {
+ return;
+ }
+
+ $node = \Drupal::routeMatch()->getParameter('node');
+ $nid = $node->id();
+
+ $result = _usagov_benefit_finder_content_check_criteria_has_child($nid);
+ if (!empty($result)) {
+ foreach ($result as $row) {
+ $errors[] = t("Can not uncheck \"Has Child\" field. There are related child values in the Life event form: $row[title] ($row[nid])");
+ }
+ }
+
+ if (!empty($errors)) {
+ foreach ($errors as $error) {
+ $form_state->setErrorByName((string) ++$error_count, $error);
+ }
+ }
+}
+
+/**
+ * It checks if criteria has child.
+ *
+ * @param int $nid
+ * Node ID of given criteria.
+ */
+function _usagov_benefit_finder_content_check_criteria_has_child(int $nid) {
+ $return = [];
+
+ $connection = Database::getConnection();
+
+ $query = $connection->select('paragraph__field_b_children', 't');
+ $query->fields('t', ['entity_id']);
+ $query->condition('t.bundle', 'b_levent_elg_criteria');
+ $result = $query->execute();
+
+ $entity_ids = [];
+ foreach ($result as $row) {
+ $entity_ids[] = $row->entity_id;
+ }
+
+ if (empty($entity_ids)) {
+ return $return;
+ }
+
+ $query = $connection->select('node_field_data', 't1');
+ $query->join('node__field_b_sections_elg_criteria', 't2', 't1.nid = t2.entity_id');
+ $query->join('paragraph__field_b_criterias', 't3', 't2.field_b_sections_elg_criteria_target_id = t3.entity_id');
+ $query->join('paragraph__field_b_criteria_key', 't4', 't3.field_b_criterias_target_id = t4.entity_id');
+ $query->fields('t1', ['title', 'nid']);
+ $query->condition('t4.field_b_criteria_key_target_id', $nid);
+ $query->condition('t3.field_b_criterias_target_id', $entity_ids, 'IN');
+ $query->orderBy('title');
+ $result = $query->execute();
+
+ foreach ($result as $row) {
+ $return[] = ['nid' => $row->nid, 'title' => $row->title];
+ }
+
+ return $return;
+}