diff --git a/cookbook/templates/shopping_list.html b/cookbook/templates/shopping_list.html
index 2d2f04285..5fb6937c2 100644
--- a/cookbook/templates/shopping_list.html
+++ b/cookbook/templates/shopping_list.html
@@ -519,7 +519,7 @@
if (entry.food.id === item.food.id) {
if (entry.unit === null && item.unit === null) {
return true
- } else if (entry.unit.id === item.unit.id) {
+ } else if (entry.unit !== null && item.unit !== null && entry.unit.id === item.unit.id) {
return true
}
}