+ if ( $cust_pkg->main_pkgnum ) {
+ $supplementals_of{$cust_pkg->main_pkgnum} ||= [];
+ push @{ $supplementals_of{$cust_pkg->main_pkgnum} }, $cust_pkg;
+ $is_anything_hidden = 1;
+ }
+}
+
+# filter out hidden package changes
+if ( $is_anything_hidden ) {
+ my @displayable_packages;
+ foreach my $cust_pkg (@packages) {
+
+ # if this package has any supplemental packages, it should remember them
+ $cust_pkg->set('_supplemental', $supplementals_of{$cust_pkg->pkgnum});
+
+ if ( $cust_pkg->main_pkgnum ) {
+
+ # it's a supplemental package of something else, and shouldn't be on the
+ # root list
+
+ } elsif ( exists( $change_to_from{$cust_pkg->pkgnum} ) ) {
+
+ # $cust_pkg is an ordered, not-yet-active package change target
+ my $change_from = $change_to_from{ $cust_pkg->pkgnum };
+ $cust_pkg->set('change_from_pkg', $change_from);
+ $change_from->set('change_to_pkg', $cust_pkg);
+
+ } elsif ( exists( $changed_from{$cust_pkg->pkgnum} ) ) {
+
+ # $cust_pkg is a canceled package changed into another packge
+ # hide it under the destination package's history
+ my $changed_to = $changed_from{$cust_pkg->pkgnum};
+ $cust_pkg->set('changed_to_pkg', $changed_to);
+ $changed_to->set('changed_from_pkg', $cust_pkg);
+
+ } else {
+
+ push @displayable_packages, $cust_pkg;
+
+ }